Forum
[Multi-lingual site] Translations of short texts in txt file
Hi,
What is the best way to handle translations that are not necessarily included in the admin through a localised region for instance. I'm thinking about short words that I'm unlikely to change and could be maintained in a text file.
Does Perch provides a helper that I could use in the template to replace the current hard coded text? Based on the current language, it would pick-up the value.
Something like what is used for the translations of the admin
{
"lang": "en-gb",
"Pages": "Pages",
"Manage Content": "Manage Content",
"Shared": "Shared",
"Perch": "Perch",
"Settings": "Settings"
}
Cheers, Robin
You can use Perch to edit any text file - it doesn't need to be an HTML page.
So if you wanted to store things as a text file, or even JSON or XML, as long as PHP can parse that file you can use Perch to edit the content just by adding a Perch Region as normal and then creating a template for the output.
Thanks for your reply.
Currently, my templates become a bit messy because I'm using <perch:if> to check the current language and to display a given translated text:
I use this approach for all the short texts. I could create <perch:content> for these texts but I feel this will decrease readability when editing the content – as there might be many of these depending on the page.
Would you have any thoughts on this? There might be a nifty perch helper I could use.
I was thinking using a plain text file to maintain these sort of translations but I have to say I don't know how to approach the problem: how could I output a translation based on the current language in the template without having to use the <perch:if>?
Many thanks, Robin
I don't think we have a good solution for you.