Comments (5)
Added the fix and a nodeJS test without browser which triggered the fix.
You may check the PR #50
from i18n4k.
Stack trace if helpful:
ReferenceError: window is not defined
ReferenceError: window is not defined
at <global>._init_properties_Locale_kt__dhcc6y(~/i18n4k/i18n4k-core/src/jsMain/kotlin/de/comahe/i18n4k/Locale.kt:27)
at <global>.get_systemLocale(kotlin/i18n4k-i18n4k-core.js:1831)
at <global>.new I18n4kConfigDefault(~/i18n4k/i18n4k-core/src/commonMain/kotlin/de/comahe/i18n4k/config/I18n4kConfigDefault.kt:24)
at <global>._init_properties_I18n4k_kt__k748j9(~/i18n4k/i18n4k-core/src/commonMain/kotlin/de/comahe/i18n4k/I18n4k.kt:7)
at <global>.set_i18n4k(~/kotlin/i18n4k-i18n4k-core.js:208)
at <global>.setLocale(src/commonMain/kotlin/Test.kt:22)
It seems like it has something to do with how the global object is set.
from i18n4k.
Hi @trentkan,
From you stack-trace I see that in this line from the Locale
module, where systemLocale
is defined, window
is referenced: https://github.com/comahe-de/i18n4k/blob/master/i18n4k-core/src/jsMain/kotlin/de/comahe/i18n4k/Locale.kt#L27
And I18n4kConfigDefault
references to systemLocale
.
As the Locale
class is essential, you cannot replace it.
I was not aware that window
is not always available. I will make a try-catch around.
Meanwhile, you may try this workaround: https://stackoverflow.com/a/46908295/2611134
Using the "global"-lib: https://www.npmjs.com/package/global
from i18n4k.
Ah, I trace that now. So anytime I create a Locale
in JS, it will reference window
when it sets systemLocale...
That being said, can we follow a similar implementation as in Java - that is, to check for presence of window.navigator.language
, otherwise fall back to default.
or perhaps just remove the concept of systemLocale
and use english for localeRef consistency?
from i18n4k.
Thank you @comahe-de. I will check this out
from i18n4k.
Related Issues (20)
- Gender-Select-Pattern
- Plural-Select-Pattern
- Declension-Pattern
- Written numbers HOT 2
- Release 0.7.0
- Percent symbols % cannot be included in messages HOT 3
- Improve LocalizedStringNumber with CLDR rules
- Named variables HOT 2
- explicit or implicit dependency between androidReleaseSourcesJar and generateI18n4kFiles HOT 5
- Parameters surrounded by single quote are not detected by the generator HOT 3
- Double single quotes are not escaped in string without parameters HOT 2
- Improve documentation about message format and message bundles
- commentLocale should be writeable
- The Locale.stripExtensions() method is not supported on Android devices with API level 26 or lower. HOT 2
- Apostrophe's character gets removed automatically HOT 1
- AGP 8.4.1 Issue HOT 1
- WASM support
- [BUG]: Accents are not exported correctly HOT 3
- Release 0.9.0
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from i18n4k.