Download Shareware and Freeware Software for Windows, Linux, Macintosh, PDA

line Home  |  About Us  |  Link To Us  |  FAQ  |  Contact

Serving Software Downloads in 956 Categories, Downloaded 50.335.158 Times

po2c 1.0.2

  Date Added: May 10, 2013  |  Visits: 442

po2c

Report Broken Link
Printer Friendly Version


Product Homepage
Download (55 downloads)



po2c is a small Perl script that takes a bunch of gettext (.po) language translation files from its command line arguments and dumps a C source code file containing all those messages and the necessary functions to use them without any other dependency.<br /><br />This is useful when you want to deploy .po translated strings to systems where no easy gettext support exist (for example, win32) or when a unique, self-contained binary without external file dependencies is convenient (for example, embedded or small systems).<br /><br />The resulting C source code file include the original and translated messages as a group of static, NULL terminated pointer-to-string arrays and the following two C functions:<br /><br />void po2c_setlang(char * lang);<br />char * po2c_gettext(char * msgid);<br /><br />The first one, po2c_setlang(), is used to set the user favourite language, probably got from him or read from any of the LANG, LC_ALL or LC_MESSAGES environment variables. the processed .po files' names must match those language strings.<br /><br />The second one, po2c_gettext(), is exactly orthogonal to the original gettext() function; the msgid is the character string to translate. It returns the translated string if found, or the same msgid otherwise.<br /><br />EXAMPLES<br /><br />Suppose you have a directory named po and the following two files,<br />po/es.po:<br /><br />#spanish translations<br />msgid "Good morning!"<br />msgstr "??N*?*Buenos d??N*?*as!"<br /><br />and po/fr.po:<br /><br />#french translations<br />msgid "Good morning!"<br />msgstr "Bon jour!"<br /><br />Then running the following command:<br /><br />po2c po/*.po > lang.c<br /><br />Will result in the following lang.c C source file:<br /><br />/* generated by po2c 1.0.2 - Do not modify */<br /><br />#include<br />#include<br /><br />static char * _po2c_msgids[] = {<br />/* 0 */ "Good morning!",<br />NULL<br />};<br /><br />struct _po2c_msg {<br />int msgid;<br />char * msgstr;<br />};<br /><br />static struct _po2c_msg _po2c_lang_fr[] = {<br />{ 0, "Bon jour!" },<br />{ -1, NULL }<br />};<br /><br />static struct _po2c_msg _po2c_lang_es[] = {<br />{ 0, "??N*?*Buenos d??N*?*as!" },<br />{ -1, NULL }<br />};<br /><br />static struct {<br />char * lang;<br />struct _po2c_msg * msgs;<br />} _po2c_langs[] = {<br />{ "fr", _po2c_lang_fr },<br />{ "es", _po2c_lang_es },<br />{ NULL, NULL }<br />};<br /><br />/* code */<br /><br />static struct _po2c_msg * _po2c_lang=NULL;<br />static int _po2c_lang_size=0;<br /><br />void po2c_setlang(char * lang)<br />{<br />int n;<br /><br />_po2c_lang=NULL;<br />_po2c_lang_size=0;<br /><br />/* if lang is NULL or "", deactivate it */<br />if(lang == NULL || *lang == '??N*?*')<br />return;<br /><br />/* searches for a valid language array */<br />for(n=0;_po2c_lang == NULL && _po2c_langs[n].lang != NULL;n++)<br />{<br />if(strcmp(lang, _po2c_langs[n].lang) == 0)<br />_po2c_lang=_po2c_langs[n].msgs;<br />}<br /><br />/* try partial searches */<br />for(n=0;_po2c_lang == NULL && _po2c_langs[n].lang != NULL;n++)<br />{<br />if(strncmp(lang, _po2c_langs[n].lang, 2) == 0)<br />_po2c_lang=_po2c_langs[n].msgs;<br />}<br /><br />/* if found, count entries */<br />if(_po2c_lang != NULL)<br />{<br />struct _po2c_msg * m;<br /><br />for(m=_po2c_lang;m->msgid != -1;m++)<br />_po2c_lang_size++;<br />}<br />}<br /><br />char * po2c_gettext(char * msgid)<br />{<br />struct _po2c_msg * m;<br />int b, t, n, c;<br /><br />/* if no language is set or msgid is empty, return msgid as is */<br />if(_po2c_lang == NULL || *msgid == '??N*?*')<br />return(msgid);<br /><br />/* binary-search for the msgid */<br />b=0; t=_po2c_lang_size - 1;<br /><br />while(t >= b)<br />{<br />n=(b + t) / 2;<br />m=&_po2c_lang[n];<br /><br />c=strcmp(msgid, _po2c_msgids[m->msgid]);<br /><br />if(c == 0)<br />return(m->msgstr);<br />else<br />if(c < 0)<br />t=n - 1;<br />else<br />b=n + 1;<br />}<br /><br />return(msgid);<br />}<br /><br />You can compile and link it against your code. There, you'll add the function prototypes and use them.<br />

Requirements: No special requirements
Platforms: *nix, Linux, Perl , BSD
Keyword: Development Development Tool Language Language Translation Translation Translation Files
Users rating: 0/10

License: Freeware
USER REVIEWS
More Reviews or Write Review


PO2C RELATED
Programming  -  Ruby Development Tool 1.0
The Ruby Development Tool is a Ruby IDE, composed of Ruby aware features/plugins for the Eclipse platform.
10.3 MB  
3D and Graphical Chat Tools  -  ChatStat Customer Interaction System 3.0.0
A completely NEW approach to live chat! Using an instant messenger interface allows you to take back your desktop while still being able to provide live chat support to your customers! Not only that, but you also can get statisitcs about your...
6.36 MB  
Web Site Promotion  -  ArtistScope Translate 1.0
Increase online sales by making your web site readable and easier to navigate for people in other countries. ArtistScope Translate enables web site proprietors to provide language translation to 27 different languages for common functions such as...
2.08 MB  
Language  -  FREE English-Spanish Translator 1.30
English to Spanish Translator employs the power of Internet machine language translation engines, and enables you to easily and exactly translate Web contents, letters, chat, and emails between English and Spanish. Main Features: - Support...
1.4 MB  
Language  -  FREE English-Chinese Translator 1.30
English to Chinese Translator employs the power of Internet machine language translation engines, and enables you to easily and exactly translate Web contents, letters, chat, and emails between English and Chinese (Chinese Simplified and Chinese...
1.17 MB  
Language  -  FREE English-Hindi Translator 1.50
English to Hindi Translator employs the power of Internet machine language translation engines, and enables you to easily and exactly translate Web contents, letters, chat, and emails between English and Hindi. Main Features: - Support translate...
1.07 MB  
Language  -  FREE English-Vietnamese Translator 1.30
English to Vietnamese Translator employs the power of Internet machine language translation engines, and enables you to easily and exactly translate Web contents, letters, chat, and emails between English and Vietnamese. Main Features: - Support...
1.41 MB  
Language  -  FREE English-French Translator 1.30
English to French Translator employs the power of Internet machine language translation engines, and enables you to easily and exactly translate Web contents, letters, chat, and emails between English and French. Main Features: - Support...
1.41 MB  
Language  -  FREE English-Korean Translator 1.30
English to Korean Translator employs the power of Internet machine language translation engines, and enables you to easily and exactly translate Web contents, letters, chat, and emails between English and Korean. Main Features: - Support...
1.41 MB  
Programming  -  Java checkstyle Tool 4.3
Checkstyle is a development tool to help programmers write Java code that adheres to a coding standard. Java checkstyle Tool automates the process of checking Java code to spare humans of this boring (but important) task. This makes it ideal for...
2.6 MB  
NEW DOWNLOADS IN SCRIPTS, DEVELOPMENT TOOLS
Scripts  -  Free Ecommerce website creator 1.2
Free Ecommerce website creator is a free PHP shop creating script. This allows you to put a online shop on your own website. Create your own free ecommerce website for Your Business. Create an online shop using easyGUI online shop creator. The...
1.44 KB  
Scripts  -  MochiGames PHP Script ZDR 1.00
MochiGames PHP Script ZDR is web site, ready for use, for flash games. These flash games are downloaded automatically by "MochiGames PHP Script ZDR" from MochiGames media. The use of the games is free, you can use your own Mochi Publisher ID and...
368.54 KB  
Scripts  -  Php Chat 2.0
Add a free php site, single sign-on and multiple skins, 100% free 1. Server Modes: The chat server has paid mode and free mode. If the free chat mode, a free chat room will be assigned to your website with your domain as the room name. 2....
938.87 KB  
Scripts  -  Nibbleblog 3.0.1
Nibbleblog it's a powerful engine for creation and manipulation of BLOG's completely free. Very simple to install and configure (Only 1 step). The database used is based on XML files and this way it is not necessary to use MySQL or similar DBMS....
371.09 KB  
Scripts  -  PHP File Manager | CloudOsys 2.9b8
CloudOsys is a PHP file manager, a tool that allows your visitors upload files such as media content directly to your website. Your visitors will upload files directly to your website, where they can share and comment on them. Through cloud...
1.41 MB  
Development Tools  -  Aml2CHM 3.50
Those who use the popular Aml Pages text editor might be looking out for a way of generating help files from their text and notes. Aml2CHM is a plug-in that was developed to offer people a quick and efficient way of converting Aml Pages documents...
549.99 KB  
Development Tools  -  VMP Viewer 1.0
This is a very rudimentary tool to visualize the VMP files generated by BrainVoyager. Useful to share files with people who do not have BV.
10 KB  
Development Tools  -  7-Zip for Script 4.42
7-Zip is a file archiver with a high compression ratio.Features:- High compression ratio in new 7z format with LZMA compression- Supported formats:- Packing / unpacking: 7z, ZIP, GZIP, BZIP2 and TAR- Unpacking only: RAR, CAB, ISO, ARJ, LZH, CHM,...
624.64 KB  
Development Tools  -  PHP Docbook Displayer for Scripts 1.0b
PHP Docbook Displayer provides XSL and CSS stylesheets, and PHP scripts, to generate easily and dynamically websites from Docbook files.It aims at simplifying to the max the web publication process : simply drop the docbook file under the site root !
102.4 KB  
Development Tools  -  WP Translate 1.0
This simple language translation plugin allows your users to quickly translate your webpages, through a widget on your blog.You have the option to select the title of the Widget, which will be displayed above the language translation form. Users...
10 KB