Skip to main content
added 183 characters in body
Source Link
Brad Bell
  • 67.6k
  • 6
  • 75
  • 145

This is in the context of a plugin, correct?

You should be able to add a craft\plugins\myplugin\translations folder with a de.php that returns an array of keyCraft/value pairs (like in craft\app\translations).Yii sees that string as:

return array(
    'myField'{attribute} cannot be blank.' => 'myFieldTranslated'{attribute} darf nicht leer sein.',
);

Where {attribute} is the dynamic part - in this case your field handle.

If I'm understanding your question correctly, there isn't a way to translate that field handle in this context because you're in charge of what it's called to begin with.

I would assume, for example, if you're using the German locale, that you would already have a German context field handle name in place already.

This is in the context of a plugin, correct?

You should be able to add a craft\plugins\myplugin\translations folder with a de.php that returns an array of key/value pairs (like in craft\app\translations).

return array(
    'myField cannot be blank.' => 'myFieldTranslated darf nicht leer sein.',
);

Craft/Yii sees that string as:

'{attribute} cannot be blank.' => '{attribute} darf nicht leer sein.',

Where {attribute} is the dynamic part - in this case your field handle.

If I'm understanding your question correctly, there isn't a way to translate that field handle in this context because you're in charge of what it's called to begin with.

I would assume, for example, if you're using the German locale, that you would already have a German context field handle name in place already.

Source Link
Brad Bell
  • 67.6k
  • 6
  • 75
  • 145

This is in the context of a plugin, correct?

You should be able to add a craft\plugins\myplugin\translations folder with a de.php that returns an array of key/value pairs (like in craft\app\translations).

return array(
    'myField cannot be blank.' => 'myFieldTranslated darf nicht leer sein.',
);