Contributors mailing list archives

contributors@odoo-community.org

Browse archives

Avatar

Re: Introducing pofiletranslate – A Tool for Translating PO Files

by
Rachid Alassir
- 13/03/2025 11:09:03

Hi Tom,

Thank you for sharing your approach!

My tool is designed to be straightforward for anyone structuring their codebase in a workspace. You simply open the terminal in the i18n folder and run:

pofiletranslate lang.po

I've considered adding a caching system to avoid re-scanning PO files and integrating AI models (like transformer-based ones from Hugging Face) for the remaining untranslated terms. However, I found that this would complicate the tool while offering diminishing returns.

Let me know if you have any thoughts!

Best regards,
Rachid


Le mer. 12 mars 2025 à 13:17, Tom Blauwendraat <notifications@odoo-community.org> a écrit :

Hi Rachid,

I don't really have the time to take a look at what you made, but I've been using standard tools and some scripting to achieve the same, revolving around the following commands:

1. Create "compendium" from existing translations:

find ../../odoo -name nl.po | xargs msgcat --use-first | msgattrib --translated --no-fuzzy -o $HOME/odoo_nl.po

2. Translate a module's PO file, making use of the compendium:

msgmerge --no-fuzzy-matching --compendium $HOME/odoo_nl.po -o $dir/$module.new.po /dev/null $dir/$module.po

It seems a similar method. I don't know if it can be of use to you

-Tom

On 3/12/25 12:37, Rachid Alassir wrote:

Hi Antonio,

By codebase, I mean the root directory of your workspace where your source code and existing translation files are located. The package searches for translations by analyzing the .po files in your project and reusing existing translations instead of relying on AI or Google Translate.

By default, the tool starts from the directory of the provided .po file and backtracks up to 4 levels (configurable with --depth) to identify common translations within your project.

Here’s an example to illustrate how it works:

workspace17/  
├── hr/                # HR-related modules  
├── account/           # Accounting-related modules  
│   ├── my_module/     # Your custom module  
│   │   ├── i18n/      # Translation folder  
│   │   │   ├── fr.po  # French translation file (target file for translation)  

If you run:

pofiletranslate account/my_module/i18n/fr.po

The tool will search for translations in fr.po files up to 4 levels above in your workspace (workspace17/), ensuring better translation consistency across your project.

Let me know if you need any further clarification!

Best regards,
Rachid


Le mer. 12 mars 2025 à 12:13, Antonio M. Vigliotti <notifications@odoo-community.org> a écrit :

Hi Rachid,

it is very interesting but what do you mean for Codebase?

I cannot understand where package search for tranlsation.

Thanks

Antonio M. Vigliotti

Mobile (+39) 342.8740910



Il 11/03/2025 21:23, Rachid Alassir ha scritto:

I apologize for the incorrectly formatted URLs in my previous email. Here are the correct links:

PyPI: https://pypi.org/project/pofiletranslate


GitHub: https://github.com/RachidAlassir/po-translate


On Tue, Mar 11, 2025, 8:39 PM Rachid Alassir <rachidalassir@gmail.com> wrote:

Dear Odoo Community,  

I’ve developed a straightforward tool to translate PO files directly from a local codebase. I noticed that translations often follow a pattern within each project, and leveraging existing translations tends to produce better results than relying on Google Translate or AI-based tools.  

**PyPI:** [https://pypi.org/project/pofiletranslate/](https://pypi.org/project/pofiletranslate/)  
**GitHub:** [https://github.com/RachidAlassir/po-translate](https://github.com/RachidAlassir/po-translate)  

I’d love to hear your feedback and suggestions!  

Best regards,  
Rachid Alassir

_______________________________________________
Mailing-List: https://odoo-community.org/groups/contributors-15
Post to: mailto:contributors@odoo-community.org
Unsubscribe: https://odoo-community.org/groups?unsubscribe

_______________________________________________
Mailing-List: https://odoo-community.org/groups/contributors-15
Post to: mailto:contributors@odoo-community.org
Unsubscribe: https://odoo-community.org/groups?unsubscribe

_______________________________________________
Mailing-List: https://odoo-community.org/groups/contributors-15
Post to: mailto:contributors@odoo-community.org
Unsubscribe: https://odoo-community.org/groups?unsubscribe

_______________________________________________
Mailing-List: https://odoo-community.org/groups/contributors-15
Post to: mailto:contributors@odoo-community.org
Unsubscribe: https://odoo-community.org/groups?unsubscribe

Reference