Escolar Documentos
Profissional Documentos
Cultura Documentos
my 2009
Welcome
najmi@kict.iiu.edu.my
Created with LATEX
Agenda
1 About
2 Internationalization
3 gettext
4 Task of developer/translator
5 Flow of the translation process
6 Codes
7 Tools
8 Route of PO to MO
9 Issues with package generated by gettext
10 Conclusion
Agenda
1 About
2 Internationalization
3 gettext
4 Task of developer/translator
5 Flow of the translation process
6 Codes
7 Tools
8 Route of PO to MO
9 Issues with package generated by gettext
10 Conclusion
Internationalization
Internationalization
Internationalization
The differences. . .
Localization
Done by translator
It can be by the
user/Developer
Submit to package
maintainer
Get credit
The differences. . .
Internationalization
Localization
Developer
Done by translator
Prepare package
It can be by the
Merge package
user/Developer
Update package
Submit to package
maintainer Announce new
package
Get credit
Give proper credit
Agenda
1 About
2 Internationalization
3 gettext
4 Task of developer/translator
5 Flow of the translation process
6 Codes
7 Tools
8 Route of PO to MO
9 Issues with package generated by gettext
10 Conclusion
gettext
gettext’s features
Part of GNU packages
Enables internationalization of software
Enables the creation of Portable Object (PO) file
Portable Object?
Gettext features
Why gettext?
Supports major characters encoding . . .
UTF-8 for an example
KDE,Gnome, Squirrelmail use it
Relatively to update and maintain
Agenda
1 About
2 Internationalization
3 gettext
4 Task of developer/translator
5 Flow of the translation process
6 Codes
7 Tools
8 Route of PO to MO
9 Issues with package generated by gettext
10 Conclusion
Agenda
1 About
2 Internationalization
3 gettext
4 Task of developer/translator
5 Flow of the translation process
6 Codes
7 Tools
8 Route of PO to MO
9 Issues with package generated by gettext
10 Conclusion
Flow of Translation
PO file’s features
It’s a raw, untranslated file
Created automatically using gettext package
Ready to be translated
MO file’s features
Compiled file, derived from PO
It’s a binary, thus machine readable
How?
Use msgfmt - message format
This will generate default name, message.mo, unless you specify
it
You can trash it out, given you just want to check the localized
stats to /dev/null
It can be reverted back, use msgunfmt
Intro to locale
Locale
Locale is the local setting of a particular country, race, venue etc
For Bahasa Melayu, the assigned locale is ms MY, where ms is for
Malay, and MY is for Malaysia
As for now, since Indonesia is using “id” , so sometimes ms is just
fine
Date sequence, for .eg dd/mm/yyyy is also fall under locale . We
also do not have Daylight Saving Time(DST), that is also locale
Charset?
Different charset support different language, characters
Includes Roman, Arabic, CJK and etc
UTF-8, UTF-16 etc
I don’t really know on this stuffs, only know Roman based and
Arabic based chars
Agenda
1 About
2 Internationalization
3 gettext
4 Task of developer/translator
5 Flow of the translation process
6 Codes
7 Tools
8 Route of PO to MO
9 Issues with package generated by gettext
10 Conclusion
# include <iostream>
# include < l i b i n t l . h>
# include <l o c a l e >
using namespace s t d ;
i n t main ( )
{
s e t l o c a l e ( LC ALL , ” ” ) ;
b i n d t e x t d o m a i n ( ” h e l l o ” , ” / u s r / share / l o c a l e ” ) ;
textdomain ( ” h e l l o ” ) ;
cout<< g e t t e x t ( ” H e l l o , w o r l d ! ” ) <<e n d l ;
cout<< g e t t e x t ( ”How are you? ” ) <<e n d l ;
return 0;
}
Executable output
$ ./hello
Hello, world!
How are you?
Executable output
$ ./hello
Hello, world!
How are you?
$ export LC_ALL=ms_MY.UTF-8
Executable output
$ ./hello
Hello, world!
How are you?
$ export LC_ALL=ms_MY.UTF-8
$ ./hello
Assalamualaikum, dunia!
Awak apa khabar?
About xgettext
Part of gettext
Extracting translatable strings from source code
# : h e l l o . cpp : 1 1
msgid ” H e l l o , w o r l d ! ”
msgstr ” ”
# : h e l l o . cpp : 1 2
msgid ”How are you ? ”
msgstr ” ”
# t r a n s l a t i o n o f h e l l o . po t o Malay
# Muhammad Najmi b i n Ahmad Z a b i d i <n a j m i . zabidi@gmail . com>, 2009.
msgid ” ”
msgstr ” ”
” P r o j e c t−Id−V e r s i o n : h e l l o \n ”
” Report−Msgid−Bugs−To : \n ”
”POT−C r e a t i o n−Date : 2009−10−23 22:08+0800\n ”
”PO−Revision−Date : 2009−10−19 18:32+0800\n ”
” Last−T r a n s l a t o r : Muhammad Najmi b i n Ahmad Z a b i d i <n a j m i . zabidi@gmail . com>\n ”
” Language−Team : Malay <t r a n s l a t i o n −team−ms@lists . s o u r c e f o r g e . net>\n ”
”MIME−V e r s i o n : 1.0\n ”
” Content−Type : t e x t / p l a i n ; c h a r s e t =UTF−8\n ”
” Content−T r a n s f e r−Encoding : 8 b i t \n ”
” X−Generator : KBabel 1.11.4\ n ”
# : h e l l o . cpp : 1 1
msgid ” H e l l o , w o r l d ! ”
msgstr ” Assalamualaikum , dunia ! ”
# : h e l l o . cpp : 1 2
msgid ”How are you ? ”
msgstr ” Awak apa khabar ? ”
python!
import g e t t e x t
g e t t e x t . b i n d t e x t d o m a i n ( ’ p i t o n ’ , ’ / u s r / share / l o c a l e ’ )
g e t t e x t . t e x td o m a i n ( ’ p i t o n ’ )
= gettext . gettext
# ...
p r i n t ( ’ python i s s i m p l e ’ )
p r i n t ( ’ as s i m p l e as t h i s ’ )
# : p i t o n . py : 6
msgid ” python i s s i m p l e ”
msgstr ” python mudah ”
# : p i t o n . py : 7
msgid ” as s i m p l e as t h i s ”
msgstr ” semudah i n i ”
Python executable
Python executable
$ python piton.py
python mudah
semudah ini
Python executable
$ python piton.py
python mudah
semudah ini
$ export LC_ALL=C
Python executable
$ python piton.py
python mudah
semudah ini
$ export LC_ALL=C
$ python piton.py
python is simple
as simple as this
<?
$language=ms MY ;
s e t l o c a l e ( LC ALL , ” $language ” ) ;
bindtextdomain ( ” i n d e x ” , ” / u s r / share / l o c a l e / ” ) ;
textdomain ( ” i n d e x ” ) ;
bind textdomain codeset ( ” i n d e x ” , ’UTF−8 ’ ) ;
echo ( ” Welcome\n ” ) ;
echo ”<br>” ;
echo ( ” Bye<br>” ) ;
echo g e t t e x t ( ” The s e t t i n g s o f ” ) . $language . ( ” i s working f i n e ” ) ;
?>
# : l a n g . php : 1 0
msgid ” Bye<br >”
msgstr ” ”
# : l a n g . php : 1 1
msgid ” The s e t t i n g s o f ”
msgstr ” ”
# : l a n g . php : 1 1
msgid ” i s working f i n e ”
msgstr ” ”
echo ( ” Welcome\n ” ) ;
echo ”<br >”;
echo ( ” Bye<br >”);
/ / echo ( ” The s e t t i n g s o f ” ) . $language . ( ” i s working f i n e ” ) ;
echo s p r i n t f ( ( ” The s e t t i n g s o f %s i s working f i n e ” ) , $language ) ;
?>
Use “sprintf”
instead of . . .
echo ( ‘ ‘ The s e t t i n g s o f ’ ’ ) . $language . ( ‘ ‘ i s working f i n e ” ) ;
will generate. . .
# : l a n g . php : 1 1
msgid ‘ ‘ The s e t t i n g s o f ’’
msgstr ‘ ‘
# : l a n g . php : 1 1
msgid ’ ’ i s working f i n e ‘ ‘
msgstr ’ ’ ‘ ‘ ’ ’
Singular Plural
cat cats
Singular-Malay Plural-Malay
Singular Plural
cat cats
boy boys
Singular-Malay Plural-Malay
Singular Plural
cat cats
boy boys
man men
Singular-Malay Plural-Malay
Singular Plural
cat cats
boy boys
man men
Singular-Malay Plural-Malay
basikal basikal-basikal
Singular Plural
cat cats
boy boys
man men
Singular-Malay Plural-Malay
basikal basikal-basikal
pensil pensil-pensil
Singular Plural
cat cats
boy boys
man men
Singular-Malay Plural-Malay
basikal basikal-basikal
pensil pensil-pensil
komputer komputer-komputer
ngettext
<?php
$n = 2 ;
echo s p r i n t f ( n g e t t e x t ( ”%d boy i s e a t i n g ” , ”%d boys are e a t i n g ” , $n ) , $n ) ;
echo ”<br>” ;
$n =1;
echo s p r i n t f ( n g e t t e x t ( ”%d c a t f a l l s ” , ”%d c a t s f a l l ” , $n ) , $n ) ;
echo ”<br>” ;
$n =1;
echo s p r i n t f ( n g e t t e x t ( ”%d t i n g k a p d i t u t u p ” , ”%d t e t i n g k a p d i t u t u p ” , $n ) , $n ) ;
echo ”<br>” ;
$n =4;
/ / i f i t goes w i t h o u t parameter %d , no s p r i n t f i s f i n e
echo n g e t t e x t ( ” F i l e i s good ” , ” F i l e s are good ” , $n ) ;
?>
Sample PO
# : n p l u r a l . php : 3
# , php−f o r m a t
msgid ”%d boy i s e a t i n g ”
m s g i d p l u r a l ”%d boys are e a t i n g ”
msgstr [ 0 ] ” ”
msgstr [ 1 ] ” ”
# : n p l u r a l . php : 6
# , php−f o r m a t
msgid ”%d c a t f a l l s ”
m s g i d p l u r a l ”%d c a t s f a l l ”
msgstr [ 0 ] ” ”
msgstr [ 1 ] ” ”
# : n p l u r a l . php : 9
# , php−f o r m a t
msgid ”%d t i n g k a p d i t u t u p ”
m s g i d p l u r a l ”%d t e t i n g k a p d i t u t u p ”
msgstr [ 0 ] ” ”
msgstr [ 1 ] ” ”
# : n p l u r a l . php : 1 3
msgid ” F i l e i s good ”
m s g i d p l u r a l ” F i l e s are good ”
msgstr [ 0 ] ” ”
msgstr [ 1 ] ” ”
Agenda
1 About
2 Internationalization
3 gettext
4 Task of developer/translator
5 Flow of the translation process
6 Codes
7 Tools
8 Route of PO to MO
9 Issues with package generated by gettext
10 Conclusion
Internationalization tools
Localization tools
POedit
Kbabel (now lokalize)
VI? Emacs ... the list may infinite up to n # of tools
Incoming . . . wish for PO Live Edit, prototype is webl10n by
gandalf
Pootle
Agenda
1 About
2 Internationalization
3 gettext
4 Task of developer/translator
5 Flow of the translation process
6 Codes
7 Tools
8 Route of PO to MO
9 Issues with package generated by gettext
10 Conclusion
PO to MO journey
Translate
PO to MO journey
Translate
Compile
PO to MO journey
Translate
Compile
Invoke
Agenda
1 About
2 Internationalization
3 gettext
4 Task of developer/translator
5 Flow of the translation process
6 Codes
7 Tools
8 Route of PO to MO
9 Issues with package generated by gettext
10 Conclusion
Issues
What are the issues?
Software may become bloated
Issues
What are the issues?
Software may become bloated
So, the user may not install everything in the first place!
Issues
What are the issues?
Software may become bloated
So, the user may not install everything in the first place!
Mozilla has its own way. . .
I saw moz2po and po2moz . . . a good news, perhaps?
Bug filed #501988 seems a good news
Issues
What are the issues?
Software may become bloated
So, the user may not install everything in the first place!
Mozilla has its own way. . .
I saw moz2po and po2moz . . . a good news, perhaps?
Bug filed #501988 seems a good news
I also have problem with UTF-8 on console.. garbled characters
Issues
What are the issues?
Software may become bloated
So, the user may not install everything in the first place!
Mozilla has its own way. . .
I saw moz2po and po2moz . . . a good news, perhaps?
Bug filed #501988 seems a good news
I also have problem with UTF-8 on console.. garbled characters
Then, I export LC ALL=C, of course I’m not happy with this
But most of the time, it works. . .
Agenda
1 About
2 Internationalization
3 gettext
4 Task of developer/translator
5 Flow of the translation process
6 Codes
7 Tools
8 Route of PO to MO
9 Issues with package generated by gettext
10 Conclusion
gettext rules
fin()
Questions?
?È@ñË@ Õ»YJ« Éë
najmi{at} kict.iiu.edu.my