[Cartoweb-users] Confused about .po files

Chris Duncan, GISmatters duncan at gismatters.com
Tue Oct 21 10:41:51 EDT 2008


I'm still struggling with this. The manual says I can test whether 
gettext is working by running scripts/testgettext.sh and 
scripts/testgettext.php. Both of those fail, so perhaps I do not have 
a working gettext. However, I note that the source code for those 
files says they only work under Linux; should I expect those test 
programs to work in Cygwin on WinXP?

The first test fails with these messages:
/cygdrive/c/.../Temp/cc6XJfWK.o:sample.c:(.text+0x88): undefined 
reference to `_libintl_bindtextdomain'
/cygdrive/c/.../Temp/cc6XJfWK.o:sample.c:(.text+0x94): undefined 
reference to `_libintl_textdomain'
/cygdrive/c/.../Temp/cc6XJfWK.o:sample.c:(.text+0x9f): undefined 
reference to `_libintl_gettext'
collect2: ld returned 1 exit status
scripts/testgettext.sh: line 68: /tmp/sample: No such file or directory

The PHP test fails with this message:
error: create /tmp/fr/LC_MESSAGES folder failed !

Does this mean that gettext is not working on my system, or are these 
errors because the tests only work under Linux?

I get no error messages when I run cw3setup.php -- the last thing it 
says is:
Launching po2mo script for projects: ACORN
Installation finished...
How can I tell if my problem is a broken gettext system vs. mistake(s) 
I'm making in configuring the .po files?

FYI: At first, I was getting additional PHP errors indicating that 
php_gettext was not installed; I un-commented the reference to that 
extension in php.ini and copied php_gettext.dll to my php/ext folder, 
and those messages disappeared.

Chris


Oliver Christen wrote:
> well, by "translation", understand "string replacement"
> practicaly, you "translate" raw strings into something more pleasant to 
> read for human.
> so the translation system is useful even if you use only one language.
> you can certainly override the template in your project and simply 
> directly replace the string inside but this will not work for the other 
> string recovered from php, ini and mapfile
> 
> regards
> Oliver
> 
>> Hi Oliver,
>>
>> Thanks so much for your patient and clarifying response. Using what 
>> you wrote and going through the Cartoweb documentation and the web 
>> again, I now realize something which was not obvious to me before: 
>> that the whole text translation scheme is a widely-used method, not 
>> limited just to Cartoweb... Since I have never developed with these 
>> tools or with internationalization before, I did not know about Gnu 
>> gettext and the po/mo files; I thought it was something special to 
>> Cartoweb. Now I can read the gettext documentation to understand much 
>> more.
>>
>> One thing is still not quite clear to me: do I need to worry about 
>> gettext, po/mo files, and all of that if I just want to change some 
>> pieces of text *without translation* (the example I used last night is 
>> changing the zoomin tool hover text from "Zoom In" to "Choose this 
>> tool and click on the map to zoom in")?  I think the answer is "yes" 
>> -- even though I am not trying to internationalize or translate or 
>> localize the text, I think I must create po files and add my new text 
>> as the "translation" for the "zoomin" msgid. Is that correct?
>>
>> One reason I am still confused on this point is that every reference 
>> to text and messages in the Cartoweb documentation talks about 
>> *translation*. There are lots of places that say, more or less, "If 
>> you need to translate this, you will need gettext... etc". I am not 
>> translating anything, so at first I thought none of those discussions 
>> applied to my situation, but now I think that changing the default 
>> text is basically the same process as translating. Is this correct?
>>
>> I will continue my reading and then try to make sense of your examples 
>> and suggestions. Thanks again for starting to point me in the right 
>> direction. And thanks to you and Bruno for pointing out that gettext 
>> is apparently needed but not working or not available on my live web 
>> server... I will look into that problem after I get my development 
>> system correctly changing the text I'm working on.
>>
>> Cheers,
>>
>> Chris
>>
>> Oliver Christen wrote:
>>> hi
>>>
>>> po are only human readable container for the text<->translation strings
>>>
>>> when running the cw3setup script, the .po get compilated by gettext 
>>> into binary .mo, these files are located in 
>>> cartoweb3/locale/*langcode*/LC_MESSAGES/*projectid.projectid.projectid*.mo 
>>>
>>> these are the files actualy used by gettext to do the string 
>>> replacement in real time.
>>>
>>> the .po contains the string you want to translate.
>>> For convenience, cartoweb include 2 scripts one can use to generate 
>>> some basic .mo for a given project: client2pot and server2pot.
>>> These script simply look inside all the files of your project for 
>>> every strings included into I18n::gt(...) call (in php file) or into 
>>> {t}...{/t} tag (in templates files). additionaly, the server2pot also 
>>> get all the layer's labels from either the layers.ini file or the 
>>> mapfile.
>>> dynamicaly generated strings will not get "recovered" by those 
>>> scripts unless someone provided some fake/hidden {t}..{/t} or 
>>> I18n::gt(...), for example for the tools's labels.
>>>
>>> client.po, server.*projectid*.po, server.po contain the raw 
>>> (untranslated) list of strings for a given project.
>>> msgid "IdRecentering"
>>> msgstr ""
>>>
>>> client.en.po, server.*projectid*.en.po, server.en.po are COPIES!!! of 
>>> the raw .po but this time they ALSO contain the translated strings 
>>> for the corresponding language.
>>> msgid "IdRecentering"
>>> msgstr "Identifiers recentering"
>>>
>>> to quickly add translations to your projects, you can easily copy the 
>>> existing .po files provided in cartoweb by default and modify them. 
>>> You will have some extra translated/unwanted strings but nothing that 
>>> cant be easily modified/removed if needed.
>>> copy ALL the .po files into your project's po folder.
>>> look at an existing demo /po folder to see whats there.
>>>
>>> if you want "clean" po files, you need to run the client2pot and 
>>> server2pot scripts to generate the RAW po files for your project and 
>>> then COPY these files and rename them with the extra 2 letters lang 
>>> tag (.po > .en.po) and EDIT them to add the translations for all the 
>>> strings you want.
>>> I would suggest moving/deleting all .po existing in cartoweb3/po/ 
>>> BEFORE doing that, as if some .po already exist, the script will try 
>>> to merge their content with the newly extracted content, which may be 
>>> problematic.
>>> so once you have emptied the /po folder, go to /cartoweb3/scripts/ 
>>> and run the command "php client2pot.php *yourprojectid*" and "php 
>>> server2pot.php *yourprojectid*"
>>>
>>> if you see  ("zoomin", "query_by_bbox") it means the strings are NOT 
>>> translated.
>>> check that gettext is installed and that it works correctly (see 
>>> documentation on how to test that 
>>> http://www.cartoweb.org/doc/cw3.5/xhtml/user.i18n.html#user.i18n.translations.debug) 
>>> restart Apache too.
>>> gettext is a bit buggy and sometimes you need to restart Apache to 
>>> see the modification you did in the .po files even after you have run 
>>> the cw3setup script to generate the .mo
>>>
>>> regards
>>> Oliver
>>>
>>> ----- Original Message ----- From: "Chris Duncan, GISmatters" 
>>> <duncan at gismatters.com>
>>> To: "Cartoweb Users" <cartoweb-users at lists.maptools.org>
>>> Sent: Wednesday, October 15, 2008 11:30 PM
>>> Subject: [Cartoweb-users] Confused about .po files
>>>
>>>
>>>> I am *not* trying to internationalize my application -- for our user 
>>>> base and local application, there's no need to support any other 
>>>> language than English.
>>>>
>>>> I would like, however, to change some of the text that appears (for 
>>>> example, in the tips that pop up when you hover over a tool like the 
>>>> zoom-in tool).
>>>>
>>>> I have tried to understand the system of .po files (defaults, 
>>>> project-specific, alternate languages, sources vs. generated, etc), 
>>>> but have become completely confused. I have not found enough info in 
>>>> the documentation or wiki to clear up my confusion.
>>>>
>>>> Could someone please provide a simple, clear, concise discussion of 
>>>> the following (if you don't have lots of time to answer, then please 
>>>> just skip to item (c) which is my most urgent question):
>>>>
>>>> (a) When, and in what order, do .po files get used? For one thing, 
>>>> I'm confused about what happens when I refresh the installation 
>>>> using cw3setup vs. what happens at runtime when someone is using the 
>>>> site. I see that there are *generated* .po files in the htdocs/po 
>>>> folder... I assume *those* are the ones that actually provide text 
>>>> to the application at runtime. But even there I find "default" and 
>>>> project-specific folders and files. Where do "source" files live, 
>>>> and what is the chain of processing that converts and/or merges them 
>>>> to create the ones I see in htdocs/po?
>>>>
>>>> (b) When do language-specific files get used? If there is both a 
>>>> client.po and client.en.po file, which one gets used? What is the 
>>>> interaction of the "generic" vs. the "language-specific" .po files?
>>>>
>>>> (c) Last, but most important to me at this time: Suppose I wanted to 
>>>> change the hover-text of the "zoom in" button to say "Choose this 
>>>> tool and click on the map to zoom in" (we have some very un-savvy 
>>>> users!). What specific steps do I follow to make that change in the 
>>>> recommended way? My project currently has *no* po folder or files... 
>>>> do I copy them from <cartowebhome>/po and then modify them? Do I 
>>>> need to run server2pot.php and client2pot.php to initialize them in 
>>>> some way? I'm totally lost on how to proceed...
>>>>
>>>> One final detail that adds to my confusion: on my development 
>>>> machine (WinXP, Apache server) I get message text like "Zoom in" or 
>>>> "Query by rectangle" when I hover over the tools; when I upload my 
>>>> project to the live web server (Windows Server, IIS) the tips are 
>>>> the message IDs instead of the text ("zoomin", "query_by_bbox"). Why 
>>>> do they differ?
>>>>
>>>> Thanks in advance to any of you who can help me understand this! 
>>>> Cheers,
>>>>
>>>> Chris
>>>>
>>>> -- 
>>>>
>>>> Chris Duncan, Ph.D.
>>>> President
>>>> GISmatters
>>>>
>>>> duncan at GISmatters.com
>>>> http://www.gismatters.com/
>>>>
>>>> 1 Tuckerman Ln
>>>> Amherst, MA 01002
>>>>
>>>> Tel: 413-549-2052
>>>> Fax: 508-637-2557
>>>> _______________________________________________
>>>> Cartoweb-users mailing list
>>>> Cartoweb-users at lists.maptools.org
>>>> http://lists.maptools.org/mailman/listinfo/cartoweb-users
>>>>
>>>
>>>
>>
>> -- 
>>
>> Chris Duncan, Ph.D.
>> President
>> GISmatters
>>
>> duncan at GISmatters.com
>> http://www.gismatters.com/
>>
>> 1 Tuckerman Ln
>> Amherst, MA 01002
>>
>> Tel: 413-549-2052
>> Fax: 508-637-2557
>>
> 
> 

-- 

Chris Duncan, Ph.D.
President
GISmatters

duncan at GISmatters.com
http://www.gismatters.com/

1 Tuckerman Ln
Amherst, MA 01002

Tel: 413-549-2052
Fax: 508-637-2557


More information about the Cartoweb-users mailing list