Giter Club home page Giter Club logo

Comments (3)

yagop avatar yagop commented on July 22, 2024

I have never used .potfile but I think the best way is writing lua tables just like:

pt_br = {
  ["Sending message"] = "Enviando mensagem"
}

Then, in the code, call to a function like __("Sending message") that will check if there is a translated
phrase for this one. Language could be configured inside data/config.lua

from telegram-bot.

JulioC avatar JulioC commented on July 22, 2024

I believe a more elaborated approach would be better, to handle cases where non positional arguments must be inserted on the string. An option would be i18n.lua, which can be added to our LuaRocks dependencies.

My suggestion is to load the translation files recursively from a folder, on load_config. The path structure would be translations/<two-letter-language-code>/<scope>.lua, where scope is common or the plugin name (this would make it easy to manage the strings). Once loaded, we can set the locale from a config and expose (it's not necessary, I believe) a method so a plugin could change it on the fly.

The project could be divided in phases: implementing i18n on the core (loading it, applying the config and the common strings); extracting the strings from plugins; translating the files.

from telegram-bot.

yagop avatar yagop commented on July 22, 2024

Nice way @JulioC but I dont have time now... 😢

from telegram-bot.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.