Git Product home page Git Product logo

turnip-calculator's Introduction

ACNH Turnip Calculator

Calculate your turnip price patterns and gain the most from the stalk market!

You can find the live calculator here.

Localizations

This app supports dynamic localization using i18next and react-i18next, with i18next-browser-languagedetector to automatically detect the user's native OS language preferences and switch the app's language accordingly.

Adding new text to localizations

As features are added to the calculator, they'll most likely not be localised immediately. To localise any new text in the app, make sure to first wrap the text in the i18n.t() method. Then, in your language's translation.json, add a new JSON key/value pair with the key used in the t() method, using your translated text as the value.

For example, let's say we're adding a new button that says "Show Current Pattern". In the component where that text would be displayed, you would instead write i18n.t("Show Current Pattern"), wrapping the statement in brackets {} if it were part of JSX code.

Then, to add a translation to your language, you'd go to your languages translation.json file, and add the following line (using Spanish as an example):

"Show Current Pattern": "Mostrar Patrón Actual",

If no key is specified in the localization files, the app will simply display whatever text is passed into i18n.t(), to avoid errors.

Creating new localizations

To localise the app to a new language, the following simple steps need to be done:

  • Create a new folder under /locales for your language using the standard two-letter language tag for your language (e.g. es for Spanish, zh for Chinese). Dialect codes are supported (e.g. en-GB for British English and pt-BR for Brazilian Portuguese).
  • In the newly created folder, copy and paste the translation.json file from one of the other languages.
  • Edit the translation.json file to translate each untranslated JSON value to the appropriate translated equivalent in your language.
  • In /src/i18n.js, create an import statement for your language, importing the translation.json file you just created. Follow the pattern used by the existing statements.
  • In the same file (/src/i18n.js), add your language to the list of languages inside the resources object within the i18n.init() method, following the pattern of other declared languages, and using the same two-letter language tag you used for the folder name in the first step.

The localization is now ready to deploy and will appear to users who use your language for their browser.

turnip-calculator's People

Contributors

devsplash avatar elxris avatar

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.