globalizejs / globalizejs/globalize
Any way to view/check loaded locales and their messages?
- Dominant language
- JavaScript
- Stars
- 4.8k
- Forks
- 585
- PR merge metrics
- No merged PRs in 30d
Description
Hello,
although I don't think there is a way from what I have seen, I might be wrong.
This would be useful in two ways for me:
1. I'd be able to check whether a message exists (at all and/or in a given language).
- Fallback to the user's second language before/instead of the normal fallback to the root
- Helpful for user-generated content that can be translated directly by others (Though, there are other ways for this.)
- Iterating through a number of strings without knowing their number.
ex.: Showing all possible values for an option. As I don't have to store the selected value, I have no point in using ids.
```json
{
"root": {
"possibleValues": {
"egg": "egg",
"cookie": "cookie",
"pizza": "pizza"
}
}
}
```
2. Debugging and finding correct locales.
- I sometimes struggle to know where which locale can be found. Looking into the live-objects would help a lot.
- ex. At some point, strings were added under `de-DE`. Late then under `de-CH`.
Now, some from `de-CH` aren't in `de-DE` and vice versa.
`de` doesn't exist or is blank `{}` (which is okay, because it's never "asked"/needed).
Afaik there is no 'good' way for them to fall back to each other (or having 'de' use both). And a "[hack](https://github.com/globalizejs/globalize/issues/357#issuecomment-70110319)" isn't a preferable way.
Therefore I'd like to track down such strings and merge them into each other (thus, having both locales a complete set of German strings).
Being able to inspect them while being in the debugger would be enough, I suppose.
(Note: I probably should check my writing tomorrow. I'm a bit tired from resolving all `E_MISSING_MESSAGE_BUNDLE` and `E_MISSING_MESSAGE` issues (gn8 for myself for now). Mostly caused by [Issue 852 - open](https://github.com/globalizejs/globalize/issues/852)
I dug as deep as I could and came across my wish (above^) from some weeks ago when I first implemented globalizejs.)
Almost forgot:
Environment: nodejs (v13, v14, v15)
globalize: v`1.6.0`
cldrjs: v`0.5.5`
```
// I'm loading:
globalize.load(
require("cldr-data/supplemental/likelySubtags.json"),
require("cldr-data/supplemental/plurals.json"),
require("cldr-data/supplemental/ordinals.json")
);
```
Contributor guide
Assessment
This issue has not been assessed yet.