Code Monkey home page Code Monkey logo

Comments (3)

alasarr avatar alasarr commented on August 20, 2024

+1 to this. As we've multiple ways for this implementation, as next steps, would be great if you can share how the API will be for a user that want to add multi-languague.

I'd keep the API as it's right now for users who don't need multi language.

from carto-react.

efernandezleon avatar efernandezleon commented on August 20, 2024

We can use a specific library to do that, there are some of them out there [1] and it seems react-intl is the most used.

It allows to include non-intrusive code to translate text and use different files for each supported language. The unique change is to change the current messages to message ids to be referenced from the language files.

[1] https://lokalise.com/blog/react-i18n-intl/

from carto-react.

aaranadev avatar aaranadev commented on August 20, 2024

I guess C4R exports a props interface to change the texts, so the responsibility is derived from the app and the multi-language is out.

An example:

<CategoryWidgetUI
 ...
  texts={{
    unlock: 'Unlock',
    lock: 'Lock',
    clear: 'Clear',
    allSelected: (data) => `${data.length ? data.length : 'All'} selected`,
  }}
/>

The CategoryWidgetUI has a prop texts (the name maybe change) where you pass the text or a function if the text dependent on a variable.

react-intl is an excellent library to use from an external app.

from carto-react.

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.