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

nested json not work #50

Closed
arthurtalkgoal opened this issue Mar 26, 2015 · 5 comments
Closed

nested json not work #50

arthurtalkgoal opened this issue Mar 26, 2015 · 5 comments

Comments

@arthurtalkgoal
Copy link

I cannot use the following notation to access ___('contact.name')_

{
  "contact": {
      "name": "姓名"
  }

}

In i18n, this is allowed:

https://github.com/mashpie/i18n-node#object-notation

Instead of calling __("Hello") you might call __("greeting.formal") to retrieve a formal greeting from a translation document like this one:

"greeting": {
    "formal": "Hello",
    "informal": "Hi",
    "placeholder": {
        "formal": "Hello %s",
        "informal": "Hi %s"
    }
}
@blowsie
Copy link

blowsie commented May 7, 2015

Duplicate of #44

@gjuchault
Copy link
Collaborator

Works !

@cbaigorri
Copy link

I am unable to get this working after this commit

Lines 295 to 303 end up creating properties if they do not exist:

if (!this.locales[locale][singular]) {
    this.locales[locale][singular] = plural ?
        { one: singular, other: plural } :
            singular;

    if (this.devMode) {
        this.writeFile(locale);
    }
}

Then in the dotNotation method they always pass the obj.hasOwnProperty(str) check.

Can you show an example of this working?

@gjuchault
Copy link
Collaborator

Please post an example of a buggy code. hasOwnProperty was there just to
avoid dot notation if not needed..

gjuchault added a commit that referenced this issue Jul 8, 2015
@gjuchault
Copy link
Collaborator

Okay I did see where was the problem.
I solved it in the last commit.

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

No branches or pull requests

4 participants