yola / gulp-static-i18n

Gulp plugin for internationalization of static assets.
MIT License
5 stars 8 forks source link

Extract and translate JSON messages #2

Closed beck closed 9 years ago

beck commented 9 years ago

Problem & Goals

Solution

Message extraction and translation injection be done via task configuration.

An idea cooked up with @thomasw - the task configuration will have a list of object keys to include & exclude when performing extraction/translation.

Example, if this is the json:

[
  "thingOne": {
    "prop": "val",
    "description": "blue fish"
  },
  "thingTwo": {
    "prop": "val",
    "description": "red fish"
  },
  "nonsense": {
    "prop": "val",
    "description": "mumbo jumbo"
  }
]

with config:

transkeys: ["description"]
ignorekeys: ["nonsense.description"]

Then we'll get the following extracted:

msgid "blue fish"
msgstr ""

msgid "red fish"
msgstr ""

Pros/Cons

beck commented 9 years ago

@stefanor - your thoughts?

thomasw commented 9 years ago

Pro: The source json committed to the repo is valid json. No modification is needed to the serialization process. Our tagging mechanism can evolve without making edits to gigantic json files.

thomasw commented 9 years ago

FYI, @imorrison

thomasw commented 9 years ago

We need to look at some site.json files and try to generate include/exclude patterns for some harder to reach keys. We also need to consider the nastiness of the markup generated by text widget usage in our site.json files. That may be prohibitive, but we won't know until we look.

stefanor commented 9 years ago

So, does that config mean that it translates both descriptions in

{
  "foo": {
    "description": "Foo",
    "bar": {
        "description": "Foo - Bar",
    },
  },
}
beck commented 9 years ago

Yes.

stefanor commented 9 years ago

Seems simple enough. :+1: