Python Forum
Seeking feedback: dynamic_i18n — automatic dynamic translation of HTML via OpenAI
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Seeking feedback: dynamic_i18n — automatic dynamic translation of HTML via OpenAI
#1
Hello everyone,

I'm relatively new to Python, and I’m currently building a chat platform. One problem I've encountered: I need to translate all HTML pages into many languages—ideally, I’d like to maintain a single source HTML in my language, and have it automatically displayed in the user’s language. The translation must be high-quality and preserve page layout (so the page doesn’t "shift" due to differences in text length).

I haven’t found any existing library that does this seamlessly at runtime with caching and layout awareness. Does anyone know of such a solution? Or would it make more sense to develop my own library—tentatively named **dynamic_i18n**—that handles dynamic translation using OpenAI, with caching, change detection, and layout stability?

Any pointers to related projects, libraries, or feedback would be greatly appreciated!

Thank you!
Reply
#2
Hello everyone,

Since I didn’t find any ready-made solutions here, I decided to build one myself.

auto-i18n-lib — a dynamic HTML internationalization library that provides:

Automatic translation of pages into the user’s language with high quality;

Layout stability (preserving structure and design even with different text lengths);

Caching of translation results for fast rendering;

Change detection so only updated content is re-translated.

I’ve already tested the library in a real project — it works as expected.

Resources:

GitHub repository: https://github.com/Aalam2000/autoi18n/

Install via PyPI: pip install auto-i18n-lib

Feedback, ideas, and pull requests are very welcome!
Reply
#3
you can use google cloud translate
there is an example of it's usage here
and here
Reply
#4
That’s not it at all. It’s harder to use, and the result isn’t right.
What I ended up with is a single library that I use during rendering. I don’t touch the pages at all—they’re in one version, in a language I understand, with no modifications.
Reply
#5
Link Removed
Consider using gettext or Flask-Babel for static i18n, but for dynamic translation with layout stability, your idea for dynamic_i18n sounds promising. Combine OpenAI for translation, Redis for caching, and use layout-aware diffing.
Gribouillis write Sep-12-2025, 03:26 PM:
Spam link removed. Please read What to NOT include in a post
Reply
#6
I didn’t quite understand what was removed. As I mentioned earlier, the library is already built and working. For now, it satisfies my needs, so I’m not planning to improve it further. If anyone has suggestions, I can update it.
Reply
#7
Nice :-)

You could add openai as dependency. This would prevent the import error, if only your package is installed and openai were not.
Almost dead, but too lazy to die: https://sourceserver.info
All humans together. We don't need politicians!
Reply
#8
Yes, added openai to dependencies. Thanks for the hint.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Updating column name with translation bobbydave 0 2,248 Sep-17-2024, 03:40 PM
Last Post: bobbydave
Information automatic document renaming lisa_d 2 2,602 Mar-20-2024, 06:34 PM
Last Post: Pedroski55
  Translation AliceCu 2 1,738 May-16-2023, 09:05 PM
Last Post: deanhystad
  Tkinterweb (Browser Module) Appending/Adding Additional HTML to a HTML Table Row AaronCatolico1 0 2,867 Dec-25-2022, 06:28 PM
Last Post: AaronCatolico1
  Matplotlib - automatic update frohr 1 2,178 Mar-29-2022, 07:05 PM
Last Post: deanhystad
  automatic create folders Mr_Kool 4 4,262 Dec-21-2021, 04:38 PM
Last Post: BashBedlam
  Translation API snippyro 0 2,013 Nov-02-2021, 01:09 AM
Last Post: snippyro
  [GoogleTrans] How can i print my translation word ?... JamieVanCadsand 7 14,760 Aug-29-2021, 12:01 PM
Last Post: Melcu54
  reading html and edit chekcbox to html jacklee26 5 5,596 Jul-01-2021, 10:31 AM
Last Post: snippsat
  Automatic user/password entry on prompt by bash script PBOX_XS4_2001 3 4,446 May-18-2021, 06:42 PM
Last Post: Skaperen

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020
This forum uses Lukasz Tkacz MyBB addons.
Forum use Krzysztof "Supryk" Supryczynski addons.