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

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

Serving Software Downloads in 976 Categories, Downloaded 30.142.908 Times

po2c 1.0.2

  Date Added: May 10, 2013  |  Visits: 245


Report Broken Link
Printer Friendly Version

Product Homepage
Download (27 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
Video Editors  -  iPod Video Encoder 1.0.2
iPod Video Encoder is a command line tool for convenient encoding of video files for use on iPod video. iPod Video Encoder project uses the ffmpeg tool for the actual encoding. It features recursive encoding of all files in a directory, and...
10.24 KB  
Development Tools  -  G-Cows 1.10
G-Cows is a software project consisting in: - definition of a scripting language designed for creation of web sites; - interpreter for the scripting language (Cows); - a makefile generator (Cows-mkgen).  Cows is the interpreter for the Cows...
Business  -  Live Operator 1
Free Live Chat service Chat with your website visitors in real-time and offer instant help to visitors when they need assistance; See their country of origin; Track their residence time on your site; Offer multi-language support by automated...
1.7 MB  
Multimedia & Graphics  -  Sh GPU Metaprogramming Language 0.8.0rc1
Sh is a predecessor to the RapidMind Multi-core Development Platform, a metaprogramming language for programmable GPUs. It is the result of research at the University of Waterloo Computer Graphics Lab.
2.65 MB  
Text Management  -  Guess language of text using ZIP 1.2
This script is a small tool for language and author identification for textfiles.
Modules  -  jL Poll 1.2 beta
*** jL_Poll Module Version 1.2 Released ****New Features:Language File included :Provided translation for French, Spanish, German and Danish. You can add more. Just comment all other Language variables except those which you want to use.More color...
20.48 KB  
Database Tools  -  Bond 2.4.3
Bond is a rapid application development (RAD) tool for linux that allows you to create network database programs quickly and easily. With this new version comes major updates in Bond XML format, and a move away from the use of C code completely!...
5.1 MB  
Network Monitors  -  Advanced Subnet Calculator 9.1
Free Subnet Calculator from Solarwinds generates all subnets with real-time DNS, PING and CIDR tests.This networking tool performs DNS resolution, address translation, supports CIDR and Address Class information. It calculates subnets based on...
9.41 MB  
Programming  -  Entrans 0.3.3
Entrans is an online collaborative translation tool used for editing and translation of PO files. It provides features such as ``dynamic'' keyboard for Indian languages and automated suggestions to help beginners and experts alike.
174.73 KB  
Modules  -  Indoeuropean Translator Widget 1.1.2
The links are displayed within a widget on the sidebar.InstallationUnpack and upload it to the /wp-content/plugins/ directory.Activate the plugin through the 'Plugins' menu in WordPress. Key features "Indoeuropean Translator Widget": - It doesn't...
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  -  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  
Development Tools  -  save2word 1.0
A simple function to copy figure from MATLAB into MS Word automatically. It is a modification of saveppt (a function in File exchange) that save figures to MS Powerpoint.
10 KB