Giter Club home page Giter Club logo

localizer's People

Contributors

beckerei avatar rugk avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

ivilata

localizer's Issues

HTML template elements are not localized

HTML template elements are not localized as expected:

<template>
	<span data-i18n="__MSG_example__">Please translate me!</span>
</template>

The issue is that they are not found by document.querySelectorAll:

Localizer/Localizer.js

Lines 283 to 286 in f6da4ca

document.querySelectorAll(`[${I18N_ATTRIBUTE}]`).forEach((currentElem) => {
const contentString = currentElem.dataset[I18N_DATASET];
replaceI18n(currentElem, contentString);
});

This affects my Thunderbird Send add-on, which uses an HTML template element in the popup. See tdulcet/Thunderbird-Send#14.

CC: @DenB10

Suggestion: avoid __MSG_*__ format

Hi! First of all, hats off to this module, it makes dynamic translation of extension HTML messages very efficient and flexible. ๐Ÿ˜„ We are using it in this extension and it works like a charm.

I was wondering whether the __MSG_*__ format in message ids really adds anything. I know it's necessary for text replacement in the manifest.json and CSS files, but with data-i18n* attributes explicitly and only referring to message ids, the format can be entirely avoided, thus avoiding a lot of noise in the HTML file. As you can see, we altered Localizer to remove that requirement and it works perfectly, even with predefined messages like @@ui_locale.

For backwards compatibility, getMessageTag may remove the __MSG_*__ wrapper if present as it does now, otherwise just use the tag as is. If you like the idea I can provide a PR, but my JS abilities are very limited.

Thanks!

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.