Is there any way to return an entire namespace via the translate function?
See original GitHub issueI have a datepicker component, which takes an object for localisation:
{
"lang": {
"placeholder": "Select date",
"rangePlaceholder": [
"Start date",
"End date"
],
"today": "Today",
"now": "Now",
"backToToday": "Back to today",
"ok": "Ok",
"clear": "Clear",
"month": "Month",
"year": "Year",
"timeSelect": "Select time",
"dateSelect": "Select date",
"monthSelect": "Choose a month",
"yearSelect": "Choose a year",
"decadeSelect": "Choose a decade",
"yearFormat": "YYYY",
"dateFormat": "M/D/YYYY",
"dayFormat": "D",
"dateTimeFormat": "M/D/YYYY HH:mm:ss",
"monthFormat": "MMMM",
"monthBeforeYear": true,
"previousMonth": "Previous month (PageUp)",
"nextMonth": "Next month (PageDown)",
"previousYear": "Last year (Control + left)",
"nextYear": "Next year (Control + right)",
"previousDecade": "Last decade",
"nextDecade": "Next decade",
"previousCentury": "Last century",
"nextCentury": "Next century"
},
"timePickerLocale": {
"placeholder": "Select time"
}
}
I have this in my translations as datepicker
, however accessing t('datepicker')
returns undefined
, presumably because it’s meant to return a string, not an object.
I can access what I need via: i18n.getResourceBundle(i18n.languages[0]).datepicker
, but I’m wondering if there is any way to do the same via the translate function itself, as this solution feels a bit hacky.
Issue Analytics
- State:
- Created 7 years ago
- Comments:8 (4 by maintainers)
Top Results From Across the Web
Essentials - i18next documentation
Namespaces are a feature in i18next internationalization framework which allows you to separate translations that get loaded into multiple files. init.
Read more >Namespaces - cppreference.com
The unique name is unique over the entire program, but within a translation unit each unnamed namespace definition maps to the same unique ......
Read more >XQuery, XPath, and XSLT Functions and Operators ... - W3C
Retrieves a document using a URI supplied as an xs:string , and returns the corresponding document node. doc-available. doc-available(xs:string ...
Read more >Namespaces (C++) - Microsoft Learn
Use a using directive in an implementation file (i.e. *.cpp) if you are using several different identifiers in a namespace; if you are...
Read more >URL dispatcher - Django documentation
Django also provides a way to translate URLs according to the active language. ... Returns a UUID instance. path - Matches any non-empty...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I solved it this way :
i18next.store.getResourceBundle(language, namespace);
@jamuhl that’s a key, not the namespace