473,378 Members | 1,396 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

The right way to do i18n


Hello,

I wonder if there is a standard for making i18n in Python projects. I
have several Python projects that are internationalized. I also have
Python packages with i18n. But it is still not clean to me what is the
recommended way to do it. Currently, I use a module called
'localization.py' with this code:

from i18n_domain import DOMAIN
import gettext
t = gettext.translation(DOMAIN,'messages',languages=['hu'])
t.install()
But I believe this is not the best way to do it. Problem one: I cannot
do unit testing and I cannot use pydoc/epydoc for my libraries. They all
use the _() function but it is installed in the main program only. What
I do now is this:

import pydoc
import sys
import __builtin__
import os
sys.argv.append('-g')
def _(s):
return str(s)
__builtin__._ = _

pydoc.cli()

But this is very very ugly.

Another problem is with libraries. I have a common library 'LibFoo' and
several projects 'Project1', 'Project2' etc. I would like to distribute
my projects and my library as distinct Python (distutil) packages. Of
course, I would like to include all messages (po, pot and mo files) with
my distributions. Is there a standard way to do it? I mean, there are
many packages out there and most of them need i18n. Also there are many
projects and they also need i18n. But how these two come together? There
should be a standard way to unify gettext messages from various
libraries. I'm thinking about a general i18n protocol, where each
package or module has a standard way to add its own messages to the whole.

Les

Sep 7 '05 #1
0 1232

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: ProgDario | last post by:
HI, I downloaded and installed the I18N pear package, but the link on the doc referring to the DB is broken. Where can I find the I18N DB? Without it I can't make it work! Thanks in...
4
by: Logan | last post by:
Is it possible to tell the wxPython widgets (e.g. file dialogs) to use another language (instead of English)? Thanks in advance for any hints! -- mailto: logan@phreaker(NoSpam).net
3
by: Albretch | last post by:
.. Can you define the Character Set for particular tables instead of databases? . Which DBMSs would let you do that? . How do you store in a DBMS i18n'ed users' from input, coming over the web...
13
by: Guido Wesdorp | last post by:
Hi! I've just released a JavaScript library to allow internationalizing JavaScript code and/or to do HTML translation from JavaScript. It's a first release, and it doesn't have all the features...
3
by: Darren Davison | last post by:
Hi, I have a documentation tool based on Java and XSLT that I want to add i18n capability to. There are around 8 stylesheets that process a Source generated by the Java code and some of the...
8
by: Alan J. Flavell | last post by:
OK, I guess I'm about ready to expose this page for public discussion: http://ppewww.ph.gla.ac.uk/~flavell/charset/i18n-weft.html Please concentrate on the content. I'm well aware that my old...
0
by: i18n-bounces | last post by:
Your mail to 'I18n' with the subject Mail Delivery (failure i18n@mova.org) Is being held until the list moderator can review it for approval. The reason it is being held: Post by...
3
by: fyleow | last post by:
I just spent hours trying to figure out why even after I set my SQL table attributes to UTF-8 only garbage kept adding into the database. Apparently you need to execute "SET NAMES 'utf8'" before...
2
by: Norman Diamond | last post by:
My C# code is I18N'ed by appropriately naming and editing .resx files. At execution time, it works. My C++ code is somewhat I18N'ed. When I put UI code in C++ I use .rc files. When I link to a...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.