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

Add support for nested objects #35

Merged
merged 1 commit into from
Sep 14, 2022
Merged

Add support for nested objects #35

merged 1 commit into from
Sep 14, 2022

Conversation

cavic19
Copy link

@cavic19 cavic19 commented Sep 11, 2022

Sometimes it is useful to structure a language package object in a nested manner. Such as

//root
{
  hello: "Hi",
  formal: {
    hello: "Hello, sir",
    small_talk: "What a beautiful weather"
  }
}

//zh-hk
{
  hello: "雷吼",
  formal: {
    hello: "你好,先生",
  }
}

Fallback mechanism, however, doesn't work for such a nested structure resulting in an undefined value.

lang.init('zh-hk');
lang.formal.small_talk; //results in undefined

This PR solves this issues by introducing recursive function, that is responsible for the fallback.

@TooBug TooBug merged commit 5c01687 into futuweb:master Sep 14, 2022
@TooBug
Copy link
Contributor

TooBug commented Sep 14, 2022

Released in 0.9.4. Thanks for your contribution!

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.

2 participants