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

Support for structured json #58

Closed
cbou opened this issue Apr 27, 2013 · 13 comments
Closed

Support for structured json #58

cbou opened this issue Apr 27, 2013 · 13 comments

Comments

@cbou
Copy link

cbou commented Apr 27, 2013

Support for structured json would be nice:

{
  "home": {
    "title": "Home",
    "subtitle": "Here is you home."
  }
}

Equivalent to:

{
  "home-title": "Home",
  "home-subtitle": "Here is you home."
}

So you can translate: i18n.__('home-title').

An alternative could be to have the possibilities to import JavaScript files and not only JSON Format.

@mashpie
Copy link
Owner

mashpie commented Apr 28, 2013

keeping on roadmap

@oliversalzburg
Copy link
Contributor

Just FYI, I implemented something similar for experimental purposes: https://github.com/oliversalzburg/i18n-node/tree/complex-backend

It uses dot notation (home.title) for structured lookups. To avoid issues with existing translation terms (which might include . in a phrase), this has to be enabled with objectNotation:true in the i18n.configure call.

There's only an implementation for single terms (no plural support). As I said, it was an experiment ;)

@juancroca
Copy link

+1

@frekw
Copy link

frekw commented Apr 14, 2014

+1!

@ronny332
Copy link

ronny332 commented Jun 6, 2014

+1

@oliversalzburg your modification works like a charm and as I can see the mustache support is at the package.json, too. please keep this fork updated as long as possible. may be it should be discussed to use you configuration modification for later versions (the naming is very obvious). at least it could be very helpful to add the changes to the documentation of your fork to make the usage easier for people who don't know this thread ;-).
for me the usage of structured language files is very important to keep the clarity. the support at webtranslateit is very useful.

@oliversalzburg
Copy link
Contributor

@ronny332 Cool to see that someone has use for it :) We use i18n-node very extensively ourselves and I'd be happy to maintain the fork if anyone is actually using it ;)

@mashpie
Copy link
Owner

mashpie commented Jun 6, 2014

please also keep reading notification - this will definitely get merged. I am again stuck in some paid jobs with critical deadlines but will catch up in july... promised :)

@oliversalzburg
Copy link
Contributor

Cool. I'll try to complete the feature then and give it a little more thought. Cheers! :)

@oliversalzburg
Copy link
Contributor

I've made a couple of changes in my fork. I made sure that pluralization works and made it possible to declare a default string to use for each object literal.

I also added some documentation: https://github.com/oliversalzburg/i18n-node/tree/complex-backend#object-notation

@juancroca
Copy link

@oliversalzburg could you make a pull request and merge your fork?

@oliversalzburg
Copy link
Contributor

@juancroca I created a PR at #114 But it's not up to me to merge :)

I'd appreciate it if you could test the branch regardless of it being merged. Cheers

@juancroca
Copy link

@oliversalzburg I did and it works wonderfully thanks hope they merge it.

@mashpie
Copy link
Owner

mashpie commented Jun 14, 2014

so this is merged, please kindly retest - thanks again to @oliversalzburg

@mashpie mashpie closed this as completed Jun 14, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants