Localization of Eclipse plug-ins using the standard wizard localization
Recently I started working on a Java project based on the Eclipse platform, RCP and PDE. For localization project I used a fairly comfortable standard localization wizard. It should be noted that there are two masters: for localizing java code and for localization of the file plugin.xml that includes the names of menus, dialogs and so on. I'll consider both.
Localization code
— select any class, package or the entire src folder

— choose in main menu "Source code" — "to Export lines" or click Alt+Shift+S and select in the context menu "Export strings"

— select a class by double click or click the button "Export"

— next in the export dialog allocated string that you do not want to localize (with Ctrl or Shift you can select multiple rows), right click the "Ignore" button, or you can remove the check mark to the left, turning it into a cross.

— it is also desirable to have a single access class, which and keep all the localization. Initially the class you want to generate, and further it can be used for subsequent localization, inserting it in a special dialog or by choosing from the dropdown list.

— marker does not require the localization of strings and array of class access, press the "Next" button. The export dialog will show a diff of the changes. As you can see, localizable strings are replaced with calls to a static variable from a class Messages, where the substituted values from the properties file, and does not require localizing the strings in your code, adding a comment of //$NON-NLS-1$, where digit specifies the number of the fragment, which is not subject of localization (as there may be several).

— click "done" and the class of localized, moving on to the next.
There is a possibility that the class will not be localized correctly if in one line to meet which do not require localization of the fragment. To test this, close the export dialog completely and re-open the list requires localization classes. Correctly localized classes will disappear from the list, and the remaining need to fix the indices $NON-NLS — starting from 1 in ascending order and correspond to the number not requiring localization of fragments. Better to fix it using the code editor of Eclipse.

After the completion of the localization code you need to copy the file messages.properties messages_ru.properties and translate all strings to Russian, it will be automatically included in the distribution.
Localization plugin.xml
— select the file plugin.xml
— press the right mouse button and select in context menu "PDE Tools" — "to Export lines"

— in the dialog that appears, remove the check mark from lines that do not require localisation

— click "Next", watch the diff

— press "finish", copy the bundle.properties in bundle_ru.properties, translate the string.
You should also include bundle_ru.properties in the build.properties to localization came with the distribution.
P. S. sorry, I couldn't localize standard dialogs-wizard, Search, Import, Export. Who knows how to do it, write me in personal mail.
Article based on information from habrahabr.ru
Localization code
— select any class, package or the entire src folder

— choose in main menu "Source code" — "to Export lines" or click Alt+Shift+S and select in the context menu "Export strings"

— select a class by double click or click the button "Export"

— next in the export dialog allocated string that you do not want to localize (with Ctrl or Shift you can select multiple rows), right click the "Ignore" button, or you can remove the check mark to the left, turning it into a cross.

— it is also desirable to have a single access class, which and keep all the localization. Initially the class you want to generate, and further it can be used for subsequent localization, inserting it in a special dialog or by choosing from the dropdown list.

— marker does not require the localization of strings and array of class access, press the "Next" button. The export dialog will show a diff of the changes. As you can see, localizable strings are replaced with calls to a static variable from a class Messages, where the substituted values from the properties file, and does not require localizing the strings in your code, adding a comment of //$NON-NLS-1$, where digit specifies the number of the fragment, which is not subject of localization (as there may be several).

— click "done" and the class of localized, moving on to the next.
There is a possibility that the class will not be localized correctly if in one line to meet which do not require localization of the fragment. To test this, close the export dialog completely and re-open the list requires localization classes. Correctly localized classes will disappear from the list, and the remaining need to fix the indices $NON-NLS — starting from 1 in ascending order and correspond to the number not requiring localization of fragments. Better to fix it using the code editor of Eclipse.

After the completion of the localization code you need to copy the file messages.properties messages_ru.properties and translate all strings to Russian, it will be automatically included in the distribution.
Localization plugin.xml
— select the file plugin.xml
— press the right mouse button and select in context menu "PDE Tools" — "to Export lines"

— in the dialog that appears, remove the check mark from lines that do not require localisation

— click "Next", watch the diff

— press "finish", copy the bundle.properties in bundle_ru.properties, translate the string.
You should also include bundle_ru.properties in the build.properties to localization came with the distribution.
P. S. sorry, I couldn't localize standard dialogs-wizard, Search, Import, Export. Who knows how to do it, write me in personal mail.
Комментарии
Отправить комментарий