Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7064803
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T04:52:45+00:00 2026-05-28T04:52:45+00:00

In short, can I use in python many .mo files for the same language

  • 0

In short, can I use in python many .mo files for the same language in the same time?

In my python application, I need to use gettext for I18N. This app uses kind of a plug-in system. This means you can download a plug-in and put it in the appropriate directory, and it runs like any other python package. The main application stores the .mo file it uses in let’s say ./locale/en/LC_MESSAGES/main.mo. And the plug-in nr 1 has its own .mo file called plugin1.mo in that same directory.

I would use this to load the main.mo I18N messages:

gettext.install('main', './locale', unicode=False)

How can I install the others too, so that all the plug-ins are translated the way they should be?

The solutions I thought of:

Should I gettext.install() in each package’s namespace? But this would override the _() defined previously and mess the future translations of the main application.

Is there a way to combine two .mo files in one (when a new plug-in is installed for example)?

At runtime can I combine them into one GNUTranslation object? Or override the default _() method that is added to the global namespace? Then, how would I go with that option?
Instead of _('Hello World'), I would use _('plugin1', 'Hello World in plug-in 1')

Note: The application is not supposed to be aware of all the plug-ins to be installed, so it cannot already have all the messages translated in its main.mo file.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T04:52:46+00:00Added an answer on May 28, 2026 at 4:52 am

    You should use different domains for each plugin. The domain can be package name to prevent conflicts.

    I do not understand why you need to translate something outside the plugin by using plugin’s domain, but if you really need to, then you should disambiguate the domain each time.

    Each plugin can provide it’s own “undescore”, readily bound to the plugin’s domain:

    from my.plugin import MessageFactory as _my_plugin
    

    Please, note, that underscore is only a convention so the extraction tools can find i18n-enabled messages in the program. Plugins’ messages should be marked with underscore in their respective packages (you do put them into separate packages, right?). In all other places, you are free to call these factories by some other name and leave underscore for the main program translation domain.

    I am less sure about .mo-files, but you can surely compile all your .po files into one .mo file. However, if plugins are written by independent uncooperative authors, there could be msgid conflicts.

    UPDATE:

    If plugins are in the same package with the main app, then there is no sense in using individual translation domains for them (this is not your case). If plugins are in the separate packages, then extraction should be done independently for those packages. In both cases you have no problem with variable _. If for some reason main app wants plugins’ translations in its code, use some other name for _, as in the answer. Of course, extraction tools will not identify anything but underscore.

    In other words, plugins should care about their translations on their own. The main app could use plugin-specific translation function as part of plug-in API. Extraction or manual addition of strings into po/mo-files are also not of concern for the main app: its up to plugin author to provide translations.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

short version: how can I get rid of the multiple-versions-of-python nightmare ? long version:
i want to point, that i am learning python since short time. The question
I know I can use something like User.sort {|a, b| a.attribute <=> b.attribute} or
To access the array indice at the xth position we can use some sort
Is there a Linux utility or a Bash command I can use to sort
I can't figure out what would be the best way to use Bucket Sort
I'd sort of like to use SQLite from within C#.Net, but I can't seem
Which algorithm does the JavaScript Array#sort() function use? I understand that it can take
Short version: How can I map two columns from table A and B if
Short story: I can't make precompiled headers work properly with gcc -c option. Long

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.