Skip to content
This repository has been archived by the owner on Dec 20, 2018. It is now read-only.

Support Localization #88

Open
jonpitch opened this issue Apr 24, 2018 · 2 comments
Open

Support Localization #88

jonpitch opened this issue Apr 24, 2018 · 2 comments
Labels

Comments

@jonpitch
Copy link

I have an application that requires localization. I'd like to be able to deliver a manifest that changes based on user locale. There's a minimal amount of content in the manifest itself that would require translation (name, short_name, description, maybe icons), but what would be nice is if that content could live in my existing translation workflow and I could populate the manifest at build time.

I think an approach could be something like:

  • detect supported languages
  • generate a manifest for each supported locale
    • use the addon to lookup a translation, something like const name = get(this, 'intl').t('ember-web-app.name');
    • update the manifest values with translations
  • user receives the manifest for their specific locale

What I'm not sure of, if this is something this addon should have as a feature or if there's another addon here that extends this one? I'm open to suggestions or ideas. I also have some cycles coming up that I could work on one or the other.

@san650 san650 added the feature label Apr 25, 2018
@san650
Copy link
Owner

san650 commented Apr 25, 2018

@jonpitch this is a great idea! I think this would be a really great feature to have. If you want to start working on it, that would be awesome, let me know if I can be of any help.

@jonpitch
Copy link
Author

Thanks @san650, I spent a little time gathering my thoughts and I have an alternate approach that I wouldn't mind your input on.

ember-i18n and ember-intl are pretty flexible in that you can use various translation file formats, specify different locations within the tree for content, that seems like overkill for ember-web-app. Instead, what I'd like to propose is perhaps ember-web-app knows about a build config, something like:

'ember-web-app': {
  enabled: true,
  locales: [{
    code: 'en-us',
    name: 'English name',
    short_name: 'English short name'
  }, {
    code: 'it-it',
    name: 'Italian Name',
    short_name: 'Italian short name'
  }]
}

ember-web-app would just be responsible for generating a set of manifest files. I think this is the most flexible, so the consumer could add something like this to their ember-cli-build.js:

const fs = require('fs');
const enUsManifestTranslations = JSON.parse(fs.readFileSync('path/to/en-us/translations.json'));

var app = new EmberApp(defaults, {
  'ember-web-app': {
    locales: [{
      locale: 'en-us',
      name: enUsManifestTranslations.name
    }]
  }
}
...

The only thing I'm not sure on is the consumer might need the ability to swap out these files in the <head>, using something like ember-cli-ifa or ember-cli-head. As the consuming app, I don't want to have to know about all the meta tags ember-web-app knows about, but I don't want ember-web-app to have to know about how I want to localize my application. What do you think?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants