Mailinglist Archive: yast-devel (53 mails)

< Previous Next >
[yast-devel] I18n - added N_() and Nn_() to Yast

Hi all,

I just have added N_() and Nn_() gettext equivalents to the latest ruby-bindings
(yast2-ruby-bindings-3.1.12).

These functions take the same arguments as _() and n_() functions but do *not*
translate the strings, they return the original untranslated values.

The side effect is that these string are found by gettext when crating POT file
and so they can be translated by translators.

Of course, to make it fully usable you need to do translation later using _()
or n_().


Some examples when this can be used:

- translating constants (see [1] for an example)

- for logging an untranslated text, but displaying translated text to the user:

begin

...
# does not translate, the exception contains the untranslated string,
# but it's recognized by gettext like normal _()
raise FooError, N_("Foo failed.")
...

rescue FooError => e
# log the original (untranslated) error
log.error e.message

# but display translated error to the user,
# _() does the actual translation
Popup.Error(_(e.message))
end


This approach can be used whenever you need both original and translated text.

Later we could use this to fix Report.Error() to log the untranslated text
instead of the translation.


Enjoy!



[1]
https://github.com/webyast/webyast/wiki/Localization#wiki-translating-constants

--

Ladislav Slez√°k
Appliance department / YaST Developer
Lihovarsk√° 1060/12
190 00 Prague 9 / Czech Republic
tel: +420 284 028 960
lslezak@xxxxxxxx
SUSE
--
To unsubscribe, e-mail: yast-devel+unsubscribe@xxxxxxxxxxxx
To contact the owner, e-mail: yast-devel+owner@xxxxxxxxxxxx

< Previous Next >
Follow Ups