DEV Community

Cover image for i18n of React with Lingui.js #1

i18n of React with Lingui.js #1

stereobooster on November 18, 2018

Everybody talking about React Hooks after React Conf. Other talks didn't get that much attention. It's a pity because there was absolutely brillian...
Collapse
 
siiidzej profile image
Václav Nosek

Hi
Thanks for simple yet powerful tutorial!

I have one question about how it works;
If you define default value (for default locale - en here) why would you also add-locale for the same language you define in Trans component?

Collapse
 
stereobooster profile image
stereobooster • Edited

I didn't understand your question. Can you provide code example, because it seems you use different terminology

Collapse
 
siiidzej profile image
Václav Nosek

I am trying your example code (github.com/stereobooster/react-lin...).

The point is; If I run npm run extract the language which is default(en) has all messages "Missing" (because it is non-sense to give translation to these as well if that is the source-of-truth).

Thread Thread
 
stereobooster profile image
stereobooster

Yes they missing, because there is no"sourceLocale": "en", otherwise they would be there. What is your question?

Thread Thread
 
siiidzej profile image
Václav Nosek • Edited

Catalog statistics is used to determine whether there are some non-translated messages therefore if You use it for any kind of automation (as a test) it wouldn't pass unless you translate the source messages as well.

I am asking if according to your opinion is this good practice or I am missing some point where you simply set "sourceLocale": "en" and problem solves? (because this isn't included in your, nor official example)

Thread Thread
 
stereobooster profile image
stereobooster

No "sourceLocale": "en" is not a solution. You can ask author for this feature

Collapse
 
dance2die profile image
Sung M. Kim

Thank you for the article there @sterobooster.

May I request if you can add links to (possibly in ToC format) next articles?

Collapse
 
stereobooster profile image
stereobooster

By any chance anyone knows how to place those dots navigation for series. I saw it in some posts, but have no idea how to do it

Collapse
 
dance2die profile image
Sung M. Kim

I've been manually entering Markdown ToC's as shown below.

# Table of Contents
1. [Example](#example)
2. [Example2](#example2)
3. [Third Example](#third-example)

## Example
## Example2
## Third Example

But not sure what you mean by dots navigation.

@andy & @ben
Is there a way to add dots navigation that @stereobooster is referring to by chance?

I was reading help document & liquid tags, but not sure if there is a standard way to add ToCs in dev.to

Thread Thread
 
andy profile image
Andy Zhao (he/him)

Think we're talking about two separate things.

I believe the dots navigation is making the post part of a series. If you're using the v1 editor, you can add a post to a series by adding a series: series name line in the front matter:
v1 editor example

If you're using the v2 editor, you can click the additional settings button next to the "IMAGES" button, and add the series from there.
v2 editor example part 1
v2 editor example part 2

For Table of Contents, we don't have anything that fully supports it yet but we have a PR that will make it a bit easier at least.

Thread Thread
 
stereobooster profile image
stereobooster

Thank you!! This is exactly what I was talking about

Thread Thread
 
dance2die profile image
Sung M. Kim

Thank you Andy 😀