Languages - formatting only

Posted on
  • Hi, I've made a fork of the Languages app just to change the pt-br locale so it will only use formatting, not translation of text. I.e. I added en-br where I removed the "trans"from the json (commit).

    trans: { yes: "sim", Yes: "Sim", no: "não", No: "Não", ok: "certo", on: "ligado", off: "desligado" }

    What motivated me was the fact that I want formatting in pt-br, but showing a few menu options in portuguese mixed with english text was odd.

    Is this common? Could this be a use case that justifies having this as an option for the users?

  • I've made this into an option on Languages:

    diff --git a/apps/locale/locale.html b/apps/locale/locale.html
    index 90a2e8d4..fa857d9f 100644
    --- a/apps/locale/locale.html
    +++ b/apps/locale/locale.html
    @@ -10,6 +10,9 @@
         <select id="languages" class="form-select">
    +    <div class="form-group">
    +      <input id="translations" type="checkbox" checked /> <label for="translations">Mark this option if you want translations for commont text like "Yes", "No", "On", "Off".</label>
    +    </div>
         <p>Then click <button id="upload" class="btn btn-primary">Upload</button></p>
         <script src="../../core/lib/customize.js"></scri­pt>
    @@ -106,12 +109,18 @@ exports = { name : "en_GB", currencySym:"£",
             const lang = languageSelector.options[languageSelecto­r.selectedIndex].value;
             console.log(`Language ${lang}`);
    +        const translations = document.getElementById('translations').­checked;
    +        console.log(`Translations: ${translations}`);
             const locale = locales[lang];
             if (!locale) {
               alert(`Language ${lang} not found!`);
    +        if (!translations)
    +          locale.trans = null;
             const codePageName = "ISO8859-1";
             if (locale.codePage)
               codePageName = locale.codePage;

    1 Attachment

    • 2022-01-15_16-01.png
  • Thanks - that's an interesting idea.

    There is actually an attempt ongoing to fix the translations properly which would allow us to separate this out - see­ssues/136

    Basically the current method (storing all translations in memory and translating on demand) is slow, doesn't always work, and will use a bunch of memory for anything more than the handful of translations we have now. So the idea is to translate apps at the time they are uploaded by detecting any text strings with /*LANG*/ before them and swapping them out.

    It's pretty much there (just needs a UI option to enable it) so once that's in and we get some proper translations, I'll pull the translations out of the locale app anyway.

  • Ok, that makes sense. Thanks for the info.

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview

Languages - formatting only

Posted by Avatar for diego @diego