angular-cli icon indicating copy to clipboard operation
angular-cli copied to clipboard

Feature Request: configure xi18n in .angular-cli.json

Open sasxa opened this issue 9 years ago • 3 comments

Bug Report or Feature Request (mark with an x)

- [ ] bug report -> please search issues before submitting
- [x] feature request

Add ability to configure xi18n in .angular-cli.json apps.

Repro steps.

Currently it's cumbersome to use xi18n command, specially in multi-app setup:

ng xi18n --output-path path/to/app1/locale --app app1
ng xi18n --output-path path/to/app2/locale --app app2
ng build --app app1 --locale de --i18n-format xlf --i18n-file path/to/app1/locale/messages.de.xlf --output-path path/to/app1/dist/de
ng build --app app2 --locale de --i18n-format xlf --i18n-file path/to/app2/locale/messages.de.xlf --output-path path/to/app2/dist/de

My npm script in real project is:

"build:app_name:i18n:de": ng build --app app_name --aot --target production --extract-css --locale de --i18n-format xlf --i18n-file \"src/apps/app_name/locale/messages.de.xlf\" --output-path dist/app_name/de

Desired functionality.

It would be nice to have ability to configure xi18n in .angular-cli.json for each app. For example:

{ name: 'app1',
  xi18n: { 
      format: 'xlf',
      outputPath: 'path/to/app1/locale',
      translations: [
        { locale: 'de', file: 'messages.de.xlf' }
      ]
    }
... },
{ name: 'app2',
  xi18n: { 
      format: 'xlf',
      outputPath: 'path/to/app2/locale',
      translations: [
        { locale: 'de', file: 'messages.de.xlf' },
        { locale: 'ru', file: 'messages.ru.xlf' }
      ]
    }
... },

My schema is a bit arbitrary and made up, but anything would work (;

Then it would be easier to use extract/build/serve/etc commands:

ng xi18n --app app1
ng xi18n --app app2
ng build --app app1 --locale de // other params from appConfig
ng build --app app2 --locale de
ng build --app app2 --locale ru

Mention any other details that might be useful.

Possible implementation of extract-i18n

    const config = new XI18nWebpackConfig({
      genDirrunTaskOptions.outputPath || appConfig.xi18n.outputPath,
      buildDir,
      i18nFormat: runTaskOptions.i18nFormat || appConfig.xi18n.format,
      locale: runTaskOptions.locale || appConfig.xi18n.translations[0].locale,
      ...
    }, appConfig).buildConfig();

sasxa avatar May 12 '17 15:05 sasxa

how is this going?

Xesenix avatar Oct 20 '17 06:10 Xesenix

Thanks for reporting this issue. This issue is now obsolete due to changes in the recent releases. Please update to the most recent Angular CLI version.

If the problem persists after upgrading, please open a new issue, provide a simple repository reproducing the problem, and describe the difference between the expected and current behavior.

alan-agius4 avatar Dec 10 '18 13:12 alan-agius4

This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.