Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improve docs on loading and applying locales #2683

Closed
wants to merge 1 commit into from

Conversation

cpsievert
Copy link

No description provided.

see the contents of this directory for the full list.
They are also available on our CDN as https://cdn.plot.ly/plotly-locale-de-ch-latest.js OR https://cdn.plot.ly/plotly-locale-de-ch-1.38.1.js
Note that the file names are all lowercase, even though the region is uppercase when you apply a locale.
This example uses Swiss-German (de-CH), but many other localizations are available (see the contents of this directory for the full list). All available locales have working date localizations, but only a subset will localize on-graph text (e.g., modebar controls). See [here](https://github.com/plotly/plotly.js/pulls?q=is%3Apr+label%3A%22type%3A+translation%22+is%3Aclosed) for a list of "fully-supported" locales.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps even better, we could ask translation authors to add an entry in a table of "fully" supported localizaion instead of linking to a list of PRs/


```html
<script src="plotly-locale-de.js"></script>
Copy link
Contributor

@etpinard etpinard May 31, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this section is misleading. A priori de-CH doesn't depend on de. At the moment, de-CH fallbacks to de just because de-CH isn't "fully" supported.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, I propose we use a "fully" supported language for this example and invite folks we want to use a non-fully supported localization (e.g. de-CH) to contribute by making a PR.

@alexcjohnson
Copy link
Collaborator

I notice that de-ch probably doesn't work the way we'd want it to. As far as I can see it's identical to de in the fields that exist, but de has added the dictionary and decimal separators. The way our localization framework is set up, that means de-ch on top of de will behave identically to just de because the fields not contained in de-ch will just be taken from de. AFAICT the only difference there should be between the two is perhaps with decimal separators (which are not part of the world-calendars/kbwood/calendars framework these originally came from, because that only deals with date & time) - so ideally we'd collapse de-ch to just:

module.exports = {
    moduleType: 'locale',
    name: 'de-CH',
    dictionary: {},
    format: {
        decimal: '.',
        thousands: ','
    }
};

Something similar can probably be said for all the regional locales currently in the repo... so before we invest more energy in spelling out how to use regional locales we should probably discuss and agree on how we really intend these to be used: do we want the regional locales to always be layered on the base language locale, or should they be independent?

We have at least one case right now where you can't layer: we have a contributed Brazilian Portuguese (pt-br) but no pt - so anyone currently using pt-br would see stripping that one down to just its differences with pt (once we have a pt) as a breaking change... on the other hand it's really nice if new translations get added to the base and they are automatically inherited by the regional locale. I'm not sure the right way to go about this. Thoughts?

@etpinard
Copy link
Contributor

I'd vote for making all locale dist files (base and regional) standalone, that way users only have to import one file to localize their app.

The only drawback I can think is for app that want to display multiple locales. In this case, importing a base locale along with its regional variants will lead to a few duplicated kBs.

@alexcjohnson
Copy link
Collaborator

I'd vote for making all locale dist files (base and regional) standalone, that way users only have to import one file to localize their app.

The only drawback I can think is for app that want to display multiple locales. In this case, importing a base locale along with its regional variants will lead to a few duplicated kBs.

What if we do this in code? ie have lib/locales/de-ch.js be:

module.exports = Lib.extendDeep({}, require('de'), {
    name: 'de-CH',
    format: {
        decimal: '.',
        thousands: ','
    }
});

Then dist/plotly-locale-de-ch.js could contain the output of that code, so it would automatically get updates from de. Users providing both as script tags would still have to carry the extra bytes, but the most byte-conscious users make custom bundles, and a bundle containing both would not have any extra bytes.

@etpinard
Copy link
Contributor

What if we do this in code? ie have lib/locales/de-ch.js be:
so it would automatically get updates from de. Users providing both as script tags would still have to carry the extra bytes, but the most byte-conscious users make custom bundles, and a bundle containing both would not have any extra bytes

Amazing. 🥇

This doesn't solve the pr-br vs pt case though. We should try to find a pt speaker.

@alexcjohnson
Copy link
Collaborator

This doesn't solve the pr-br vs pt case though. We should try to find a pt speaker.

That's a (hopefully) uncommon case, where 3/4 of the language's speakers are in a single non-base region (and 20x the number in the base region) - I have no idea how different the two are, but I think it's OK to leave as is for now - hopefully a user from Portugal will come along and make us a pt and then we can collapse the two if they do have enough overlap that it's justified.

@etpinard
Copy link
Contributor

Moved to #2991

@etpinard etpinard closed this Sep 10, 2018
@etpinard etpinard deleted the localization-note branch September 10, 2018 15:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants