question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to deal with defaultLanguage

See original GitHub issue

Hi @GertjanReynaert, before going forward I wanted to say thank you for your work, great job!

I opened this issue since I’m a bit confused about how to deal with the defaultLanguage.

Let’s say you wrote all the message descriptors in your components and then used babel-plugin-react-intl to extract them to a directory, you google a while about how to join them and found this package, so you read the docs and create a script like this:

import manageTranslations from 'react-intl-translations-manager';

const defaultLanguage = 'en-US';

manageTranslations({
  messagesDirectory: 'src/translations/extractedMessages',
  translationsDirectory: 'src/translations/locales/',
  languages: [defaultLanguage], // any language you need
});

you run the script and voila, everything worked as expected, but there is a file that grabs your attention: whitelist_en-US.json, so you read the docs again and found this:

languages (optional, default: []) What languages the translation manager needs to maintain. Specifying no languages actually doesn’t make sense, but won’t break the translationManager either. example: for [‘nl’, ‘fr’] the translation manager will maintain a nl.json, fr.json, whitelist_nl.json and a whitelist_fr.json file

You think: “I can have more control with this feature, great!”

And then you modify some defaultMessage, run the script again, and you get:

image

So you are stuck, you was expecting the generated json to update with the latest change you’ve introduced but instead you got all this…

So the question would be:

Shouldn’t it work like I’m expecting or if not, why?

Thanks!

Issue Analytics

  • State:open
  • Created 7 years ago
  • Reactions:3
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
GertjanReynaertcommented, Jan 13, 2017

First: thx for using this package!

Second: sorry for the confusion around the default language!

I haven’t found a good way to deal with the defaultLanguage yet, but ATM, it’s not really recommended to include the defaultLanguage in your languages array. At the start of this package I approached it like this: since your defaultMessages are in your defaultLanguage, you don’t need to manage them, so you don’t need to include the language in the array of languages to be managed.

That being said, we should come up with an approach to help people out (either a way to include the default language, or better docs) since this is a frequently returning question.

1reaction
vilvadotcommented, Jan 25, 2017

First of all thanks for the tool @GertjanReynaert Im using it and its amzazing. Im also having questions regarding this feature.

I have it included because I want it to generate the ‘en.json’ file from my messages, but I don’t like to get that output.

Maybe we should be able to define a defaultLanguage, the manager will then generate the defaultMessages .json with that name but ignore it when comparing files?

That way we get the file generation and nice translations management. just an idea!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Change the default input language for Windows
Under Installed services, click Add. In the Add Input Language dialog box, click the language that you want from the Input language list,...
Read more >
Change your language on the web - Computer - Google Support
Sign in to your Google Account. On the left, click Personal info. Under "General preferences for the web," click Language and then Edit...
Read more >
How to Change Your Default Language in Google Chrome
1. Chrome Settings 2. Advanced Settings 3. Chrome Language Settings
Read more >
Change the Default Content Language
In the Skillport Header, click The Library. · Click the Content language drop down. · Select a language from the list. Optionally, click...
Read more >
Change your service project's default language
Before you begin, make sure that the language you want to set as default has up-to-date translations and is enabled. Learn how to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found