openSUSE:WebYaST Internationalization

Jump to: navigation, search

Internationalization

WebYaST uses ruby gettext for managing translation. An general overview how gettext in conjunction with ruby/rails works can be found in this tutorial.

A description how to manage po, mo and pot files can be found here.

Here a short summary:

Tagging Text for Translation

Initialize gettext and set text in the controller for translation

class MyPluginController < ApplicationController
  before_filter :login_required
  layout "main"
  # Initialize GetText and Content-Type to use yast_webclient_my_plugin.mo
  init_gettext "yast_webclient_my_plugin"  

  def index
    puts _("This text will be translated")
  end
end

Set text for translation in the views

<html>
<head>
  <title><%= _("This text will be translated") %></title>
</head>
<h2><%=_("This text will be also translated.")%></h2>
</html>

"#{name}" style isn't supported. Use % style instead.

_("it's #{name}") => _("it's %s") % name
                  => _("it's %{name}") % {:name => name}

Location of po,mo and pot files

Development

---web-client
     |
     +---pot
     |   (location of all generated pot-files)
     |
     +---plugins
     |      |
     |      +---<plugin-name>
     |              |
     |              +---po
     |              |   (location of translations)
     |              |
     |              +---locale
     |                  (location of all mo-files)
     |
     +---webclient
            |
            +---po
            |   (location of all webclient core translations)
            |
            +---locale
            |   (location of all webclient core mo-files)
            |
            +---public
                  |
                  +---vendor (This directory will be NOT packaged for RPM)
                         |
                         +---text
                               |
                               +---locale
                                   (location of all plugin mo files)

Installed RPMs

srv
 |
 +---www
      |
      +---yast
           |
           +---po
           |   (location of all webclient core translations)
           |
           +---locale
           |   (location of all webclient core mo-files)
           |
           +---vendor
                 |
                 +---plugins
                        |
                        +---<plugin-name>
                                 |
                                 +---po
                                 |  (location of plugin translations)
                                 | 
                                 +---locale
                                    (location of plugin mo-files)
  

/srv/www/yast/locale/

Creating POT files

Run "updatepot" task to create pot-file using updatepot task.

for all modules:

web-client> rake updatepot

for single plugins only:

web-client> cd plugins/plugin_foo
web-client/plugins/plugin_foo> rake updatepot

In both cases the pot file(s) will be generated in

web-client/pot

These files has to be shipped to the translators.

Managing po files

Po files will be generated by the translators. One po file has been generated for each language. Just copy the po files into the concerning po directory by creating language sub-directories:

  ---po
      |
      +---en/yast2_webclient_<plugin-name>.po
      +---de/yast2_webclient_<plugin-name>.po
      +---fr/yast2_webclient_<plugin-name>.po
      +---fr_CH/yast2_webclient_<plugin-name>.po
      +---ja/yast2_webclient_<plugin-name>.po
      +...
      +..
      +.

You can also use the rake command

rake fetch_po <directory from which the po files have to be copied>

which copies all po files to the right directory.

After you have updated the po files you have to call rake makemo which is described in the next chapter.

Creating mo files

Run "makemo" task to create mo-file using makemo task.

for all modules:

web-client> rake makemo

for single plugins only:

web-client> cd plugins/plugin_foo
web-client/plugins/plugin_foo> rake makemo

It generates mo-files under concerning locale/`` directory.

Do not forget to restart the web server.