12:34:26 #startmeeting 12:34:27 Meeting started Fri Apr 30 12:34:26 2010 UTC. The chair is mether. Information about MeetBot at http://wiki.debian.org/MeetBot. 12:34:29 Useful Commands: #action #agreed #halp #info #idea #link #topic. 12:34:42 #meetingtopic How to do I18N through gettext 12:34:43 mether: thanks :) 12:34:48 #meetingname How to do I18N through gettext 12:34:49 The meeting name has been set to 'how_to_do_i18n_through_gettext' 12:35:03 Hello everyone. I am Naveen Kumar, a Fedora contributor and will be leading the "How to do I18N through gettext" workshop today 12:35:14 #link https://fedoraproject.org/wiki/A_Short_Tutorial_On_i18n_Through_gettext 12:35:21 We will be internationalizaing a classic Hello World program in C 12:35:35 First step, run emacs 12:36:11 nkumar: done 12:36:19 type ALT+x 12:36:26 type ansi-term in the lower window 12:36:31 press return twice 12:37:01 nkumar: got terminal window in emacs 12:37:16 yep! same ^ 12:37:26 nkumar: got the ansi terminal up could type indic as well 12:37:32 in super user mode (root user) type yum install @development-tools 12:37:39 #commandline yum install @development-tools 12:37:49 yum install @-support 12:37:56 For Hindi I would do something like: 12:38:04 #commandline yum install @hindi-support 12:38:17 then 12:38:18 #commandline yum install ibus ibus-table* 12:38:45 #chair nkumar 12:38:46 Current chairs: mether nkumar 12:39:10 Tell me when you have installed them: 12:39:24 nkumar: the development tool size is very large almost 41MB 12:39:56 nkumar: by development tools are you asking for a specific one ? 12:40:01 ok for the time you can ignore them, we will install as required... 12:40:15 i wanted to ensure gettext is there... 12:40:20 yum install gettext 12:40:22 Yes its taking some time . 12:40:43 & yum install gcc 12:41:04 gettext is likely installed already. just make sure you have gcc installed and we can install anything else as we go along 12:41:18 yep, just install gcc 12:41:23 nkumar: gcc and gettext installed. 12:41:39 ok then we will move ahead 12:41:44 create a directory with name gettextsession 12:41:51 #commandline mkdir gettextsession 12:42:00 #commandline cd gettextsession 12:42:30 If you know, write a hello world program in C, otherwise download http://nkumar.fedorapeople.org/helloi18n/helloworld/helloworldnaive.c 12:42:36 #commandline wget http://nkumar.fedorapeople.org/helloi18n/helloworld/helloworldnaive.c -O helloworld.c 12:43:13 tell me when you are done... 12:43:23 if you do know to write one, just download it 12:43:37 done 12:43:42 done 12:43:51 run helloworld.c in an editor (vi, gedit etc) 12:44:00 In this file include the following:#include & #include in the beginning 12:44:07 #addinfile #include 12:44:14 #addinfile #include 12:44:25 #addinfile #define _(String) gettext(String) 12:45:08 done? 12:45:26 yep 12:45:44 yes 12:45:45 in the main() function add the following in the beginning 12:45:51 #addinfile setlocale(LC_ALL,""); 12:45:57 #addinfile bindtextdomain("helloworld","/usr/share/locale"); 12:46:05 #addinfile textdomain("helloworld"); 12:46:21 nkumar: this is right on top of the main fnction? 12:46:28 FranciscoD, yes 12:46:32 err 12:46:45 begining of the main function 12:46:48 FranciscoD, inside it. 12:46:59 main(){ setlocale(LC_ALL,"");... 12:47:12 mether:thanks :) 12:47:20 done 12:47:40 Now change printf("Hello World\n"); with printf(_("Hello World\n")); 12:47:45 nkumar, can you explain what these functions do, one by one? 12:47:47 #replaceinfile printf("Hello World\n"); printf(_("Hello World\n")); 12:48:49 bindtextdomain("helloworld","/usr/share/locale"); binds helloworld domain to Mesage catalog locale repo /usr/share/locale 12:49:36 Message Catalog, is a database of local language strings in some file 12:49:48 for those joining in late, feel free to refer to http://meetbot.fedoraproject.org/fedora-classroom/2010-04-30/how_to_do_i18n_through_gettext.2010-04-30-12.34.log.txt 12:49:58 textdomain("helloworld"); sets current domain to be helloworld 12:50:07 nkumar: is message catalog like Mo file ? 12:50:13 nkumar: please define "domain" 12:50:17 yep 12:50:50 generally an application will have one domain of all translated strings 12:51:03 it is a meta name for applications string 12:51:08 for example 12:51:26 all the strings in gedit is in domain "gedit" 12:51:30 in file gedit.mo 12:51:54 But an application can chose to have more than one domain for an app. 12:52:05 so in this case its helloworld 12:52:12 yes 12:52:29 If I call textdomain("helloworld"); 12:52:37 it sets current domain to helloworld 12:53:09 I can set it to something else with the effect, then the translated messages will appear from that domain 12:53:11 nkumar: why should it be binded to /usr/share/locale ? has it got anything to do with where gettext looks? 12:53:18 nkumar: so its mean when we compile that program than we have a helloworld.mo file at given location? 12:53:35 it is a standard location for storing message catalogs in linux 12:53:47 But you can also change it to something else 12:53:58 yep 12:54:22 praveenkumar: .mo file can be copied to /usr/share/locale at any time 12:54:26 why would a app have more than one domain? 12:55:06 Generally it is not the case, but If suppose an application used some parts from another app 12:55:20 mether: gtk may have its own domain and gedit may have its own domain, I think 12:55:20 then it does not make sense to translate it again 12:55:29 ah ok 12:55:37 j4v4m4n: ok 12:55:43 now understood :) 12:55:47 Makes sense 12:56:08 j4v4m4n: yes, than can be the case, thanks :) 12:56:31 should we move ahead: 12:57:36 yes 12:57:46 yep 12:57:48 should we compile the program? 12:57:58 Not now... 12:58:00 Now change printf("Hello World\n"); with printf(_("Hello World\n")); 12:58:04 pavi: patience ;) 12:58:09 #replaceinfile printf("Hello World\n"); printf(_("Hello World\n")); 12:58:16 Your C program is now internationalized... 12:58:38 nkumar: so when im coding, its my responsibility to do all this? 12:58:55 yep, programmer's 12:59:03 or do i code normally and someone else internationalizes it? 12:59:39 Normally you should, if you do not do it, we will have more jobs for i18n engineers :-P 12:59:44 * FranciscoD notes to use i18n henceforth 12:59:46 ;) 12:59:49 nkumar: what is use of libintl.h library ? 13:00:02 definitions for whatever new stuff youve added 13:00:09 yep 13:00:12 ok 13:00:16 praveenkumar: its another header file 13:00:24 got it 13:00:37 Now remember it is the responsibility of gettext functions to extract local strings at runtime 13:01:13 printf(_("Hello World\n")); here printf expects an 8bit string and nothing else 13:01:54 this is what _("Hello World\n") provides but in a local script extracted from appropriate domain and language selection 13:02:37 Tell me when to move ahead? 13:02:43 please contiue 13:02:49 s/contiue/continue 13:02:56 #commandline mkdir po/ 13:03:06 #commandline xgettext -d helloworld -o po/helloworld.pot -k_ -s helloworld.c 13:03:11 #commandline cd po 13:03:31 #commandline ls 13:03:53 you should now see helloworld.pot 13:04:02 in this directory "po" 13:04:53 continue? 13:05:02 yes it has a msgid with string :) 13:05:13 yep 13:05:26 #commandline mkdir hi 13:05:31 #commandline cp helloworld.pot hi/helloworld.po 13:05:37 #commandline cd hi 13:05:50 run helloworld.po in an editor (vi, gedit etc) 13:07:11 ok 13:07:12 continue? 13:07:17 yep please 13:07:30 Edit the line # FIRST AUTHOR , YEAR. 13:07:30 nkumar: its show the details of program 13:08:02 you put small -o instead of -O 13:08:36 me yevlempy isn't able to join today coz he's suffered an accident 13:08:39 nkumar: where we have to put? 13:08:43 sorry, what does it show 13:08:47 duh! :D 13:08:49 sorry 13:09:07 nkumar: ^^ 13:09:13 that was a mistake, yep 13:09:20 praveenkumar: the pot file in the hi folder 13:09:46 po folder should have helloworld.po 13:10:08 nkumar: yeah got helloworld.po 13:10:34 does it look something like http://nkumar.fedorapeople.org/helloi18n/helloworld/po/hi/helloworld.mo 13:10:53 does it look something like http://nkumar.fedorapeople.org/helloi18n/helloworld/po/hi/helloworld.po 13:11:03 ^ mo file ? 13:11:07 ahh ok 13:12:34 is it alike? 13:13:46 nkumar: yeah 13:13:50 yes 13:14:10 Edit the line # FIRST AUTHOR , YEAR, 13:14:20 I would Write: 13:14:34 # Naveen Kumar , 2010 13:15:08 Normally you should provide # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER also 13:15:16 But I am skipping that for now 13:15:29 ok 13:15:38 delete the line : #, fuzzy 13:15:52 done 13:15:57 done 13:16:05 #replaceinfile "Project-Id-Version: PACKAGE VERSION\n" "Project-Id-Version: helloworld 1.0\n" 13:16:17 copy the date of "POT-Creation-Date:" to "PO-Revision-Date:" 13:16:31 #editinfile "Last-Translator: FULL NAME \n" 13:17:13 #editinfile "Language-Team: LANGUAGE \n" to "Language-Team: Hindi \n" alike 13:17:39 #replaceinfile "Content-Type: text/plain; charset=CHARSET\n" "Content-Type: text/plain; charset=UTF-8\n" 13:17:52 tell me when this much is done... 13:19:16 done 13:19:44 After this select your keyboard from iBus/xkb/scim etc 13:19:54 switch to your native keyboard 13:20:08 edit the string: msgstr "" 13:20:23 For Hindi I would do: 13:20:30 msgstr "नमस्कार दुनिया\n" 13:21:08 if you cannot see it run "yum install @hindi-support" 13:21:38 Tell me when you are done: 13:21:59 & close the file.... 13:23:03 Done? 13:23:06 nkumar: how to type hindi letter with keyboard? 13:23:30 praveenkumar: for now just copy & paste 13:23:40 j4v4m4n: ok 13:24:01 j4v4m4n: thanks :) 13:24:16 praveenkumar: you can use ibus if you are interested to learn to type in Hindi 13:24:28 tell me when you all are done? 13:24:31 done 13:24:52 close the file 13:24:53 #commandline msgfmt helloworld.po -o helloworld.mo 13:25:07 Be super user (root) 13:25:28 copy helloworld.mo to /usr/share/locale//LC_MESSAGES/ 13:25:38 for hindi I would do something like: 13:25:45 #commandline cp helloworld.mo /usr/share/locale/hi/LC_MESSAGES/ 13:26:17 Tell me when you are done? 13:27:27 also exit su mode 13:28:51 If you cannot generate helloworld.mo, tell me right away with error message: 13:29:28 donr 13:29:33 *done 13:30:47 done 13:31:36 #commandline cd ../../ 13:31:40 I forgot \n in msgstring and got a error for that which I corrected 13:31:42 #commandline gcc -o helloworld helloworld.c 13:31:44 nkumar: i have a error 13:31:49 set your locale, for Hindi I would do something like: 13:31:55 #commandline export LANG=hi_IN.UTF-8 13:32:00 #commandline ./helloworld 13:34:00 what is the error? 13:35:39 im getting an error too http://fpaste.org/tAer/ 13:35:44 nkumar: ^ 13:37:16 nkumar: helloworld.po:21: `msgid' and `msgstr' entries do not both end with '\n' 13:37:16 msgfmt: found 1 fatal error 13:37:19 kishan installed gcc and gettext ? 13:37:34 pavi_: yes 13:37:54 praveenkumar: yep they should both end with "\n" 13:38:13 put a "\n" at the end of msgstr string 13:38:38 kisan: can you paste your helloworld.c 13:38:44 or link to it 13:39:13 nkumar: yes, 1 min 13:39:43 nkumar: http://fpaste.org/i1BU/ 13:40:07 nkumar: i already put "\n" after that it show same error 13:40:46 kishan: its _string 13:41:00 kishan: check line 5 13:41:13 praveenkumar: link to your file... 13:41:17 thanks pavi: 13:41:24 thanks pavi_ 13:41:28 oh, thanks pavi_ :) 13:42:17 nkumar: I was able to compile but I still get the english version :( 13:42:22 it is working for me 13:42:42 nkumar: http://www.fpaste.org/MiIV/ 13:43:07 pavi: did you export LANG=hi_IN ? 13:43:16 praveenkumar: why is there a \n in last line . remove it 13:43:36 it should only be in msgstr "...\n" 13:43:43 j4v4m4n: yes did that 13:44:25 praveenkumar: your source file did not have \n 13:44:31 it is evident in msgstr 13:44:34 pavi: paste your po file and source file 13:44:41 done, code runs, but I'm getting in English 13:44:59 me too getting in english :( 13:45:19 praveenkumar: so remove \n from msgstr and last line 13:45:27 meejan: kishan copied the po files to /usr/share/locale? 13:45:33 meejan: link to your po and .c file? 13:45:35 nkumar: ok 13:46:22 I will run with post po edit commands once again... 13:46:24 j4v4m4n: no, i think 13:46:25 j4v4m4n: http://fpaste.org/dQ3a/ 13:46:35 #commandline msgfmt helloworld.po -o helloworld.mo 13:46:41 Be super user (root) 13:46:51 #commandline cp helloworld.mo /usr/share/locale/hi/LC_MESSAGES/ 13:46:56 #commandline cd ../../ 13:46:57 nkumar: got without error 13:47:00 j4v4m4n: my po file is alright and I pasted mo file at locale 13:47:03 #commandline gcc -o helloworld helloworld.c 13:47:08 set your locale, for Hindi I would do something like: 13:47:13 #commandline export LANG=hi_IN.UTF-8 13:47:18 #commandline ./helloworld 13:47:59 pavi: paste your po file and cp command 13:48:01 praveenkumar: are you getting text in local script 13:49:06 nkumar: yep got in hindi नमस्कार दुनिया 13:49:19 praveenkumar: super! 13:49:48 pavi: paste your po file and cp command 13:49:58 j4v4m4n: where do i have to paste the po file? 13:50:13 you mean helloworld.po only, isnt it? 13:50:14 kishan: fpaste 13:50:21 ok 13:50:24 doing 13:51:30 http://fpaste.org/09SW/ 13:51:39 j4v4m4n: ^ 13:52:57 kishan: what is your cp command? 13:52:58 i pasted my correct po file on fpaste http://www.fpaste.org/Fzd7/ 13:53:05 j4v4m4n: nkumar I forgot to change charset to UTF-8 in po file . 13:53:43 cp helloworld.mo /usr/share/locale/hi/LC_MESSAGES/ 13:53:47 j4v4m4n: ^ 13:53:48 got Hello world in telugu అందరికీ నమస్కారం 13:54:13 kisan: Were you able to generate .mo file 13:54:26 nkumar: yes 13:54:55 kisan: and did you copy it to ommandline cp helloworld.mo /usr/share/locale//LC_MESSAGES/ 13:55:04 nkumar: yes 13:55:11 praveenkumar: you need not keep "FIRST AUTHOR", just add your name see http://fpaste.org/09SW/ 13:55:11 what is your language 13:55:25 nkumar: i am not getting in the local string 13:55:26 hi 13:55:32 hindi, i mean 13:55:37 j4v4m4n: ok 13:56:12 pranay_09: show us your c file, po file and cp command 13:56:29 kisan: can you paste your command lines 13:57:01 kishan: can you paste your command lines 13:57:11 ok, 1 min. 13:57:22 pavi: $ ./helloworld 13:57:23 എല്ലാവര്‍ക്കും കൂപ്പുകൈ 13:57:44 j4v4m4n: c file http://www.fpaste.org/mwHZ/ 13:58:11 pranay_09: 1. check is if you exported locale correctly 2. Copy in correct place 3. check the charset in po file 13:58:19 pranay_09: you missed one line textdomain("helloworld"); 13:58:40 thanks j4v4m4n 13:58:41 * j4v4m4n had same mistake :( 13:59:11 pranay_09: see http://fpaste.org/i1BU/ 13:59:23 j4v4m4n: I cant see your helloworld as I installed only hindi and telugu fonts :P 13:59:46 pavi: yum install @malayalam-support :) 14:00:00 pavi: I could see your helloworld 14:00:16 j4v4m4n: is there a single command to install all indian languages liek in debian ? 14:00:57 pavi: I guess right now not there 14:01:18 nkumar: http://www.fpaste.org/SJ5J/ 14:02:49 kishan: looks alright 14:03:16 pavi: hmm, but im getting in English :( 14:03:19 kishan: $echo $LANG 14:03:37 hi_IN 14:03:51 pavi: ^ 14:03:58 pavi: for i in "languages"; do yum install $i-support;done 14:05:02 kishan: it should have .UTF-8 14:06:17 kishan: did you change to _(String) 14:06:17 pavi: i think kishan forgot to use export LANG=hi_IN.UTF-8 and he used export LANG=hi_IN 14:07:14 guys who all are not getting local script.... 14:07:24 pranay_09: did you get it? 14:07:48 j4v4m4n: ya just 1 min 14:09:14 Ok those who got it, do you have questions? 14:09:34 j4v4m4n: In the malayalam packages why are there many fonts under smc ? 14:10:30 pavi: because we have many free fonts :) 14:10:35 nkumar: what is difference in .pot or .po? 14:11:04 pot stands for portable object template file 14:11:16 nkumar: why should LANG be hi_IN.UTF-8 ? Is it compulsory to specify encoding ? 14:11:22 it is a template file which is copied to all the languages and then translated.... 14:11:47 pavi: it is optional for languages that uses only one encoding 14:12:13 yep thanks j4v4m4n 14:12:20 j4v4m4n: illustrate with example 14:13:05 I am manufacturing example export LANG=hi_IN.UTF-8 or export LANG=hi_IN.ISCII 14:13:40 pavi: en_US has many different encodings 14:14:02 j4v4m4n: like ASCII or western european ? 14:14:11 en_US.ISO-8859-15 and en_US.UTF-8 14:14:15 or iso-8859-1 14:14:34 ahh ok 14:15:03 POT files are used to copy only 14:15:15 one untouced file 14:15:25 sorry, i got disconnected :( 14:15:35 and Portable Object files (PO files) are translated only 14:15:42 could someone paste please ? 14:15:46 kishan: your cfile 14:16:04 kishan: fpaste 14:16:28 kishan: http://meetbot.fedoraproject.org/fedora-classroom/2010-04-30/how_to_do_i18n_through_gettext.2010-04-30-12.34.log.txt 14:16:34 kishan: did you change to _(String) 14:17:23 kishan: sorry did you miss textdomain 14:17:33 j4v4m4n: http://fpaste.org/kHkZ/ 14:17:33 thanks 14:17:38 you would not have got po file with _(String) 14:17:48 nkumar: yes, I changed 14:18:02 nkumar: yes, I missed, reading up the logs 14:18:12 kishan: and went through all the commands again 14:18:38 nkumar: yes, but still getting in English :( 14:19:45 Can you run "yum install @hindi-support" in su mode 14:20:14 nkumar: already done 14:20:29 getting "Nothing to do" 14:20:46 kishan: are you getting gedit in Hindi? 14:20:48 ok run "LANG=hi_IN.UTF_8 gedit" 14:21:03 and if it comes in hindi 14:21:28 no, its coming in English :( 14:21:45 Then there is something wrong with your locale 14:21:57 hmm, yes, i suppose so :( 14:22:27 kishan: what version of fedora are you using? 14:22:28 kishan which fedora are you using ? 14:22:35 fedora 12 14:23:10 did yum really finish installing hindi lang pack ? 14:23:33 pavi: yes! 14:23:38 kishan: yum install @hindi-support 14:23:47 do it again 14:24:13 nirik: forwarding you an email that you might enjoy, in just a moment :) 14:24:30 pavi: nkumar http://fpaste.org/pRsw/ 14:24:34 did it again 14:25:53 kishan: try this again as normal user LANG=hi_IN.UTF_8 gedit 14:25:59 kishan: something wrong with your locale, try yum install glibc-common 14:26:34 kishan: what is the output of locale command? 14:26:39 pavi: getting in English only 14:26:53 huh something wrong in IITK mirror ?? 14:27:48 j4v4m4n: you mean "cp helloworld.mo /usr/share/locale/hi/LC_MESSAGES" command? 14:27:56 Any one else is still struggling? 14:28:02 kishan: just run "locale" 14:28:16 oh :) 14:28:19 pranay_09: got it in hindi ? 14:29:07 Or any questions? 14:29:10 j4v4m4n: http://fpaste.org/cK52/ 14:29:18 actualy i am getting error that CHARSET is not a portable encoding name 14:30:22 i am trying it to do it again the whole process 14:31:18 nkumar: how many encodings are there for indic languages? 14:31:35 pranay_09: That line should be "Content-Type: text/plain; charset=UTF-8\n" 14:32:48 pavi: I only know of ISCII and UTF-8, UTF-16 (-le,-be) & UTF-32 (,-le,-be) 14:33:37 kishan: sometimes a locale change needs a reboot, can you reboot and select Hindi at login screen? 14:33:57 j4v4m4n: hmm.. ok , trying 14:35:21 Guys, I think we can continue this discussion on email, if there are not many questions... 14:35:45 mailto: nkumar@redhat.com 14:36:41 Or else you can run steps in #link https://fedoraproject.org/wiki/A_Short_Tutorial_On_i18n_Through_gettext 14:39:01 ok Thank you for the session 14:39:05 nkumar: sure 14:39:47 j4v4m4n: still English! :( 14:40:18 kishan: :( does login screen lists languages? 14:40:23 Kishan: I think we can interact on email... 14:41:29 j4v4m4n: no, i did "LANG=hi_IN.UTF_8 gedit" , and got in English 14:41:44 FranciscoD: Did you get it running... 14:43:01 nkumar: ok, i will try it again and see 14:43:31 ok, thanks to everybody.... 14:43:40 ending the meeting... 14:43:46 #endmeeting