Giter Club home page Giter Club logo

Comments (2)

jenseng avatar jenseng commented on May 30, 2024

probably won't deal w/ this just yet; as a workaround for now, you can just add one more runtime extensions script to your page

ideally though it would be great to just have a single runtime dependency that includes i18n, i18nliner's extensions, and all the plugins' extensions

from i18nliner-js.

Download avatar Download commented on May 30, 2024

ideally though it would be great to just have a single runtime dependency that includes i18n, i18nliner's extensions, and all the plugins' extensions

This is what I did in my fork.

The readme for this project says:

You'll need to shoehorn i18n.js into your app, which (as of this writing) is not CJS-compatible

However, there is i18n-js which is CJS compatible. So I think you could make an endpoint in i18nliner, i18nliner/i18n that would just require('i18n-js'), then add the extensions to it and re-export it. I did that here:
https://github.com/Download/i18nline/blob/master/lib/i18n.js

You can repeat the same trick for react-i18nliner.

This solution requires end users to include 18nliner via react-i18nliner but I don't think that's so bad.

I don't think you should try to include all plugin's runtime extensions from i18nliner, because the runtime extensions need to be browserified/webpacked, and AFAIK there is no good way to do dynamic includes without bloating the web bundle. Best to make sure all require calls have a literal string as their parameter so they are statically analyzable. This sort of rules out requiring stuff based on plugin configuration.

On another note, it's actually pretty tricky to get the configuration to the client, because the .18nrc file is only available on the server. Most of the options there apply only to the CLI, but there are some options related to the inferred key names that are needed on the client. If you configure these in .18nrc then the CLI will use the option, but you still have to do something to make sure this option is also set on the runtime... I am using the defaults to get around this because I haven't found a neat solution yet... My change of allowing config from package.json makes this problem worse, because you could potentially just require('./i18nrc') from the client to serialize the settings (they would be included in the browserified/webpacked bundle), but it sucks to include the whole package.json...

from i18nliner-js.

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.