The XTrkCAD Wiki : Internationalization

HomePage :: PageIndex · RecentChanges · Login/Register
Most recent edit on 2008-01-28 20:35:00 by TimShead

Deletions:
- XTrkCad locale path: ~/install/xtrkcad/locale



Edited on 2008-01-18 17:25:25 by BobBlackwell [Modified Paragraph formats]

Additions:
Localization - "L10N" for short - is the process of creating new locales (language translations) for an existing application. For convenience, XTrkCAD provides several "make targets" to automate the localization process. In this document, those make targets are used.
If you are adding a new locale to XTrkCad, edit the src/xtrkcad/app/i18n/CMakeLists.txt file. There is a variable called XTRKCAD_LOCALES in the top of the file. This is the list of the supported locales. Add the new locale on it's own line and keep the list sorted alphabetically. Here is an example of what the list might be:
Defines if gettext is used or not. If this is set to OFF, then the following parameters are ignored and no gettext support is compiled in the XTrkCad.
Optional parameter. Translation program to edit the .po files. If this is set, "msgtranslate-<locale>" targets are created in i18n/Makefile to make the translation process easier(?). These targets calls the translation program with the .po file as a command line parameter.
4) Build the project. This will automatically update or create the required .po files to the source tree:
5) Translate. If you set the XTC_TRANSLATOR parameter in step 3, you may use the make targets that was created by CMake:
6) Install XTrkCad and the language files. The language files (.mo files) will be created automatically:
If you are using English locale in your Linux session, you can still test XTrkCad with any other locale by setting the LANG environment variable in terminal. In this example, Finnish locale is used:
If translation needs to be modified, go back to step 5. When done, continue to step 8.
Fingers(tm) and Keyboard Buttons(tm) are both non-renewable natural resources, so it's recommended to combine the steps 5 to 7 into a one single command line while translating and testing:
Then it's easy to hit the UpArrow and Enter to make the changes to translation and then test again.
This means that every source file that contains translatable strings should include "i18n.h" file, and the code like this:
The macro _() has two jobs. It makes the string visible to xgettext string extractor utility, and it does the run time translation. To make things more complicated, there are some exceptions:
The N_() macro means "no-operation", and it's there only for telling the xgettext that the string should be added to .pot file for translation. The actual run time translation is done on the next line with _() macro. The _()
Gettext has also functions for plural forms and solving ambiguities, but currently they are not implemented in XTrkCad. If these are added later, new macros (xgettext keywords) must be added to XGTKEYWORDS in i18n/CMakeLists.txt.
To enable or disable gettext internationalization in XTrkCad, set the parameter XTRKCAD_USE_GETTEXT to ON or OFF with ccmake.


Deletions:
Localization - "L10N" for short - is the process of creating new locales (language translations)
for an existing application. For convenience, XTrkCAD provides several "make targets" to automate the localization
process. In this document, those make targets are used.
If you are adding a new locale to XTrkCad, edit the
src/xtrkcad/app/i18n/CMakeLists.txt file. There is a variable called
XTRKCAD_LOCALES in the top of the file. This is the list of the supported
locales. Add the new locale on it's own line and keep the list sorted
alphabetically. Here is an example of what the list might be:
Defines if gettext is used or not. If this is set to OFF, then the
following parameters are ignored and no gettext support is compiled in
the XTrkCad.
Optional parameter. Translation program to edit the .po files. If this is
set, "msgtranslate-<locale>" targets are created in i18n/Makefile to make
the translation process easier(?). These targets calls the translation
program with the .po file as a command line parameter.
4) Build the project. This will automatically update or create the required
.po files to the source tree:
5) Translate. If you set the XTC_TRANSLATOR parameter in step 3, you may use
the make targets that was created by CMake:
6) Install XTrkCad and the language files. The language files (.mo files) will
be created automatically:
If you are using English locale in your Linux session, you can still test
XTrkCad with any other locale by setting the LANG environment variable in
terminal. In this example, Finnish locale is used:
If translation needs to be modified, go back to step 5. When done,
continue to step 8.
Fingers(tm) and Keyboard Buttons(tm) are both non-renewable natural
resources, so it's recommended to combine the steps 5 to 7 into a one single
command line while translating and testing:
Then it's easy to hit the UpArrow and Enter to make the changes to
translation and then test again.
This means that every source file that contains translatable strings should
include "i18n.h" file, and the code like this:
The macro _() has two jobs. It makes the string visible to xgettext string
extractor utility, and it does the run time translation. To make things more
complicated, there are some exceptions:
The N_() macro means "no-operation", and it's there only for telling the
xgettext that the string should be added to .pot file for translation. The
actual run time translation is done on the next line with _() macro. The _()
Gettext has also functions for plural forms and solving ambiguities, but
currently they are not implemented in XTrkCad. If these are added later, new
macros (xgettext keywords) must be added to XGTKEYWORDS in i18n/CMakeLists.txt.
To enable or disable gettext internationalization in XTrkCad, set the parameter
XTRKCAD_USE_GETTEXT to ON or OFF with ccmake.




Edited on 2008-01-18 16:36:33 by TimShead

Deletions:
XTRKCAD_LOCALEDIR (Default: /usr/share/locale)
The base directory to install and search for the locale files. This
directory is compiled in to the XTrkCad executable, and also used when
installing the locale files with "make install". The locale files will be
installed as:
<XTRKCAD_LOCALEDIR>/<locale>/LC_MESSAGES/xtrkcad.mo
For example:
~/install/xtrkcad/locale/fi/LC_MESSAGES/xtrkcad.mo



Edited on 2008-01-17 21:27:36 by TimShead [Assign category]

Additions:
CategoryDevel



Edited on 2008-01-17 21:02:23 by TimShead

Additions:
$ cd ~/build/xtrkcad

SET(XTRKCAD_LOCALES
  en_GB
  en_US
  fi
  sv
  ...
  )

3) Configure your build environment:
$ ccmake ~/src/xtrkcad

$ make

$ make msgtranslate-<locale>

$ make msgtranslate-fi

$ make install

$ ~/install/xtrkcad/bin/xtrkcad

$ export LANG=fi_FI.UTF-8
$ ~/install/xtrkcad/bin/xtrkcad

$ make msgtranslate-<locale> && make install && \
   ~/install/xtrkcad/bin/xtrkcad

printf("Hello, World!\n");

printf(_("Hello, World!\n"));

char * myString = "Some important string";
printf( myString );

char * myString = N_("Some important string");
printf( _(myString) );


Deletions:
$ cd ~/build/xtrkcad
...
SET(XTRKCAD_LOCALES
en_GB
en_US
fi
sv
)
...
3) Configure your building environment:
$ ccmake ~/src/xtrkcad
$ make
$ make msgtranslate-<locale>
$ make msgtranslate-fi
$ make install
$ ~/install/xtrkcad/bin/xtrkcad
$ export LANG=fi_FI.UTF-8
$ ~/install/xtrkcad/bin/xtrkcad
$ make msgtranslate-<locale> && make install && \
~/install/xtrkcad/bin/xtrkcad
printf("Hello, World!\n");
printf(_("Hello, World!\n"));
char * myString = "Some important string";
printf( myString );
char * myString = N_("Some important string");
printf( _(myString) );




Edited on 2008-01-17 20:57:20 by TimShead

Additions:
- CMakeBuild

Deletions:
- http://www.xtrkcad.org/Wikka/CMakeBuild



Oldest known version of this page was edited on 2008-01-17 20:56:46 by TimShead []
Page view:

Localization


Localization - "L10N" for short - is the process of creating new locales (language translations)
for an existing application. For convenience, XTrkCAD provides several "make targets" to automate the localization
process. In this document, those make targets are used.

GNU/Linux


The following setup is used in this manual:

1) Change to CMake build directory:
$ cd ~/build/xtrkcad

2) If you are editing an existing locale, go straight to step 3.

If you are adding a new locale to XTrkCad, edit the
src/xtrkcad/app/i18n/CMakeLists.txt file. There is a variable called
XTRKCAD_LOCALES in the top of the file. This is the list of the supported
locales. Add the new locale on it's own line and keep the list sorted
alphabetically. Here is an example of what the list might be:

...
SET(XTRKCAD_LOCALES
en_GB
en_US
fi
sv
)
...

3) Configure your building environment:
$ ccmake ~/src/xtrkcad

The following parameters are relevant to translation progress:

XTRKCAD_USE_GETTEXT (Default: ON)
Defines if gettext is used or not. If this is set to OFF, then the
following parameters are ignored and no gettext support is compiled in
the XTrkCad.

XTRKCAD_LOCALEDIR (Default: /usr/share/locale)
The base directory to install and search for the locale files. This
directory is compiled in to the XTrkCad executable, and also used when
installing the locale files with "make install". The locale files will be
installed as:
<XTRKCAD_LOCALEDIR>/<locale>/LC_MESSAGES/xtrkcad.mo
For example:
~/install/xtrkcad/locale/fi/LC_MESSAGES/xtrkcad.mo

XTC_TRANSLATOR (Default: <empty>)
Optional parameter. Translation program to edit the .po files. If this is
set, "msgtranslate-<locale>" targets are created in i18n/Makefile to make
the translation process easier(?). These targets calls the translation
program with the .po file as a command line parameter.

4) Build the project. This will automatically update or create the required
.po files to the source tree:
$ make

5) Translate. If you set the XTC_TRANSLATOR parameter in step 3, you may use
the make targets that was created by CMake:
$ make msgtranslate-<locale>
Change <locale> to the locale you want to edit, for example:
$ make msgtranslate-fi

6) Install XTrkCad and the language files. The language files (.mo files) will
be created automatically:
$ make install

7) Test your translation:
$ ~/install/xtrkcad/bin/xtrkcad
If you are using English locale in your Linux session, you can still test
XTrkCad with any other locale by setting the LANG environment variable in
terminal. In this example, Finnish locale is used:
$ export LANG=fi_FI.UTF-8
$ ~/install/xtrkcad/bin/xtrkcad
If translation needs to be modified, go back to step 5. When done,
continue to step 8.

8) Update modified or add new locale file to version control:
src/xtrkcad/app/i18n/locale/<locale>.po


Useful tip

Fingers(tm) and Keyboard Buttons(tm) are both non-renewable natural
resources, so it's recommended to combine the steps 5 to 7 into a one single
command line while translating and testing:

$ make msgtranslate-<locale> && make install && \
~/install/xtrkcad/bin/xtrkcad

Then it's easy to hit the UpArrow and Enter to make the changes to
translation and then test again.


Internationalization

"Internationalization" - or "I18N" for short - is the process of writing software that can display different locales.
All strings that are to be visible to the end user should be internationalized.
This means that every source file that contains translatable strings should
include "i18n.h" file, and the code like this:

printf("Hello, World!\n");

should be written like this instead:

printf(_("Hello, World!\n"));

The macro _() has two jobs. It makes the string visible to xgettext string
extractor utility, and it does the run time translation. To make things more
complicated, there are some exceptions:

char * myString = "Some important string";
printf( myString );

converts to:

char * myString = N_("Some important string");
printf( _(myString) );

The N_() macro means "no-operation", and it's there only for telling the
xgettext that the string should be added to .pot file for translation. The
actual run time translation is done on the next line with _() macro. The _()
macro cannot be used in the string initializer.

Gettext has also functions for plural forms and solving ambiguities, but
currently they are not implemented in XTrkCad. If these are added later, new
macros (xgettext keywords) must be added to XGTKEYWORDS in i18n/CMakeLists.txt.

To enable or disable gettext internationalization in XTrkCad, set the parameter
XTRKCAD_USE_GETTEXT to ON or OFF with ccmake.


Related links


GNU gettext


CMake

SourceForge.net
Valid XHTML 1.0 Transitional :: Valid CSS :: Powered by Wikka Wakka Wiki 1.1.6.3
Page was generated in 0.1426 seconds