enupal / translate

Translate your website templates and plugins into multiple languages for Craft CMS. Bulk translation with Google Translate or Yandex.
https://enupal.com/craft-plugins/translate
Other
11 stars 2 forks source link

Use all static message strings from translations directory #10

Open piotrpog opened 6 years ago

piotrpog commented 6 years ago

Can plugin be modified so that it uses all strings used inside 'translations' directory, even if these are not directly used in templates?

Use case: to make dropdown fields labels multilingual, i use them as kays inside static messages translations files. So, no actual translation strings are directly used in template, but like this: {{entry.dropdown_field.label|t}}

andrelopez commented 6 years ago

Yes, but you need to create a private file in your templates e.g: _customTranslations.twig

In this file please add any translation that you want e.g the string from your dropdown fields: templates\_customTranslations.twig

{{"label1"|t}}
{{"label2"|t}}
{{"label3"|t}}

Go to Enupal Translate and you'll see these translation strings as pending, select the language that you want to translate, add the translation, save it and go to the entry where you're using the field, switch the language that you want and you'll be able to see the translations.

Best,

piotrpog commented 6 years ago

@andrelopez Thanks for reply. Indeed, its possible to use this walkaround, but I was asking if it was possible to just implement this functionality in plugin :)

andrelopez commented 6 years ago

Hi @piotrpog

Could you please share a better example? I'm not sure if I follow your requirement

Best,

piotrpog commented 6 years ago

@andrelopez Sorry for not replying earlier.

Its just about where plugin should look for translation strings. Currently it looks inside template files. I propose that it also checks translation files (inside translations folder) for any strings that are not currently used in templates.

sarianth commented 5 years ago

Hi @piotrpog

When you say translation files (inside translaion folder) did you mean .php or .twig files?

piotrpog commented 5 years ago

@sarianth I mean php files inside translations directory. Now it just scans twig files in templates directory.

stevenvandemoortele commented 5 years ago

+1 for adding support for translation files inside translation folder. I use freeform for most of my forms and the recommended translation method for form labels is creating a freeform.php translation file. Currently these files can't be translated using enupal translate.