![]() In the Extract Translation Key dialog that opens, provide a meaningful name to the translation key. Right-click a word in a template and select Extract Translation from context menu: To speed up this process, the Symfony Plugin provides the Extract Translation action, which lets you select a word and create a translation out of it. Extracting translationsĬreating translations requires writing the code-making use of the Translator service and then creating the translation in a resource file. The translation key will be added to resource file where you can provide the correct value for it. To apply it, place the caret at the key, press Alt+Enter, and choose Symfony: Add translations. ![]() This way, you know when a translation needs to be supplied in one of the resource files.įor translation keys, a quick-fix is available, which can create the corresponding translation key in the resource file. When you try to use a translation key or domain that does not exist, PhpStorm displays the corresponding warning from the Missing Translation inspection. In this case, choose a specific declaration to navigate to from the popup menu. Alternatively, Control+LeftClick the usage.Īpplications that require translations typically have multiple resources for every locale. To navigate to the declaration of a key or a domain, place the caret at its usage and press Control+B. Code navigation for translations or domains Provide a domain, which determines the resource file to fetch the translation from.Ĭompletion for keys and domains is available in both PHP code and Twig templates. Provide a key, which determines the translation to fetch. ![]() In the editor, press Control+Space to invoke code completion and do any of the following: You can query the Translator service for specific messages by key and domain. Code completion for translations or domains Translation completion and navigation is also available when translating Symfony forms. Note that for these features to work, the Translator service for the Symfony application needs to be enabled. Additionally, it lets extract translations from within controllers and templates. It warns whenever a non-existing translation is used. The Symfony Plugin assists with internationalization (commonly abbreviated as i18n) by providing completion for known translations and domains. Depending on the types of an application being developed, you may have to work with the Symfony's Translation component to abstract strings and locale-specific pieces into resources/files that provide the correct data for a specific locale.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |