I am using a lot of translation with the |t / |translate filter. But the client wants to be able to edit those translations in the admin panel.

So, I thought about different ways to achieve that. Please drop your opinion.

  1. Create a new filter, refering to a table under the globals in admin panel. Never did that, but should be possible, right?
  2. Try to get and edit the translation arrays in the phps in the translation folder (dont know how thats possible)
  3. Don't use the |t filter at all. Instead maybe a matrix field type with 2 fields: one not translateable with the origin language and one translatable text field that is translateable. Disadvantage: instead of the convinient |filter I have write code to get the right translation. Also: what about performance?

You could try if the Translate plugin for Craft CMS could help you out. You can use this plugin as a base for you own and save the values in a custom table and use the registerTranslateSources hook to return the values from your table

That would be some kind of mix between options 1 and option 2. Both are totally possible. I created such a plugin for my company too. Collect all uses of |t and check if there is a language fallback in the plugin translation file or if there is one in the default Craft translation file. If not you can mark the word as "untranslated" if yes save the record as translated. In your cp you'll display all your records with the hint if they are translated or not

| improve this answer | |
  • Thanks Robin, the plugin is actually helpful! Just, the changes in the translations doesn't have any effect, even if the translation php have writing rights. Any idea? – Jan Feb 20 '18 at 15:58
  • Yes that's unfortunately the case because there are bugs in this plugin. Like I said, you could use that one as your base and create something new – Robin Schambach Feb 21 '18 at 7:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.