Skip to content

feat(compiler-cli): add i18n parameters to tsconfig - #16365

Closed
ocombe wants to merge 1 commit into
angular:masterfrom
ocombe:feature-i18n-params-tsconfig-16232
Closed

ocombe wants to merge 1 commit into
angular:masterfrom
ocombe:feature-i18n-params-tsconfig-16232

Conversation

@ocombe

@ocombe ocombe commented Apr 27, 2017

Copy link
Copy Markdown
Contributor

What kind of change does this PR introduce?

[x] Feature

What is the current behavior? (You can also link to an open issue here)
Right now you cannot add existing i18n parameters to tsconfig, see issue #16232

What is the new behavior?
You can now add parameters to your tsconfig that will be used when you don't provide cli parameters. It works with ng-xi18n and ngc. Since they both have some parameters with a similar name, those options in tsconfig have a slightly different name compared to the cli parameters (with the prefix source for ng-xi18n and the prefix target for ngc).

Does this PR introduce a breaking change? (check one with "x")

[x] No

@ocombe ocombe added area: i18n Issues related to localization and internationalization action: review The PR is still awaiting reviews from at least one requested reviewer feature Label used to distinguish feature request from other issues labels Apr 27, 2017
@ocombe
ocombe requested a review from vicb April 27, 2017 07:50

@vicb vicb Apr 27, 2017 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can remove this line "you should ..."
same below

Comment thread packages/compiler-cli/src/codegen.ts Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

|| sourceFormat at the end (useful when they are the same)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For xmb/xtb source & target format are different, this could lead to bugs. The only case where this would work would be for xlf and it's already the default format.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please take the opportunity of this PR to clean the (...)! hack.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As a general comment on this PR, "source" is confusing because it relates to the file being written which is counter-intuitive - same for "target".

Can you think about better names ?

@vicb vicb left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See inline comments + need tests

@vicb vicb added action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews and removed action: review The PR is still awaiting reviews from at least one requested reviewer labels Apr 27, 2017
@ocombe
ocombe force-pushed the feature-i18n-params-tsconfig-16232 branch from 7c6100a to 9d7d54e Compare April 28, 2017 12:03
Comment thread packages/compiler-cli/src/codegen.ts Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be locale ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wanted to be sure if you really paid attention to the code.

Jokes aside, good catch, fixed

@ocombe
ocombe force-pushed the feature-i18n-params-tsconfig-16232 branch from 9d7d54e to 6befe68 Compare April 28, 2017 12:14
Comment thread packages/compiler-cli/src/codegen.ts Outdated

@vicb vicb Apr 28, 2017 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

move this to the top with other parameters ?
explain why we do || options.i18nTranslationFormat (ie most files contain both messages and translations)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same thing here, move init to the top, missing i18nTranslationFormat here

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

format could not be null -> || '' at the end

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

forget my first comment, you have updated the API

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't use "i18nTranslationFormat" for the extraction (this is ng-xi18n, not ngc)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

move init at the top

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

specify the possible values in the comment

@vicb vicb left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • see inline comments,
  • add tests

@ocombe
ocombe force-pushed the feature-i18n-params-tsconfig-16232 branch from 6befe68 to 8a24b8c Compare April 28, 2017 16:52

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

set the default to xliff

Comment thread packages/compiler-cli/src/extractor.ts Outdated

@vicb vicb May 1, 2017 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

revert |null

also for the other methods if possible

Comment thread packages/compiler-cli/src/main.ts Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why this change ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's the only way that I found to add the unit test. I can remove it, but I'll have to remove the test as well

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same, add xliff by default

@ocombe
ocombe force-pushed the feature-i18n-params-tsconfig-16232 branch from 8a24b8c to cbf49f1 Compare May 2, 2017 11:46
@ocombe ocombe mentioned this pull request May 2, 2017
20 tasks
@vicb vicb removed the action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews label May 10, 2017
@vicb

vicb commented May 10, 2017

Copy link
Copy Markdown
Contributor

LGTM, needed before merge:

  • @ocombe to update the tests according to discussions,
  • travis should be green (the failure does not seem to relate to the changes).

You can now add parameters to your tsconfig that will be used when you don't provide cli parameters. It works with ng-xi18n and ngc. Since they both use some parameters with a similar name, those options in tsconfig can have a slightly different name compared to the cli parameters.

Closes angular#16232
Fixes angular#16235
@ocombe
ocombe force-pushed the feature-i18n-params-tsconfig-16232 branch from cbf49f1 to 71a7a3b Compare May 12, 2017 13:47
@ocombe ocombe added the action: merge The PR is ready for merge by the caretaker label May 12, 2017
@vicb

vicb commented May 15, 2017

Copy link
Copy Markdown
Contributor

Blocked because missing approval.

@alexeagle could you please review. Thanks.

@alexeagle alexeagle left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/cc @vikerman

locale?: string;

// path & name for the extracted messages file
outFile?: string;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is probably confusing.

"compilerOptions": {
  "outDir": "foo",
  "out": "bar"
},
"angularCompilerOptions": {
  "outFile": "baz"
}

I think either these options need to have i18n in the name, or be nested:

"angularCompilerOptions": {
  "i18n_msgs": {
    "extract": {
      "outFile": "msgs.xtb"
    },
    "merge": {
      "i18nFile": "msgs.xtb"
    }
  }
}

WDYT?

@ocombe ocombe May 16, 2017 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We used the names of the current cli options (when possible). We can nest them though, what do you think @vicb ?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's not possible to nest the options:
type CompilerOptionsValue = string | number | boolean | (string | number)[] | string[] | MapLike<string[]> | PluginImport[];

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't MapLike<string[]> the way to nest options? TypeScript does nest them, eg. compilerOptions.paths

i18nFormat?: string;

// locale of your application for extracted messages file
locale?: string;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was expecting multiple locales to appear here. Users shouldn't have N tsconfig files (and note that the tsconfig "extends" behavior doesn't cover unknown config properties like "angularCompilerOptions")

@ocombe ocombe May 16, 2017 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the locale used for extracted messages, which is the main locale of your application. There is only one here since you only do one extraction.
You are referring to translationLocale?: string; which is the locale used when you compile the application. I had a comment there that @vicb told me remove which was something like "only use this if you have one tsconfig file / locale".
I agree that it would be better if we could compile all locales in one command, but that is not possible yet. There's a bit refactor coming for the compiler and it will probably change at that point, but for now we can only compile for one locale.

@chuckjaz chuckjaz removed the action: merge The PR is ready for merge by the caretaker label May 19, 2017
@mhevery
mhevery force-pushed the feature-i18n-params-tsconfig-16232 branch from ae67092 to 71a7a3b Compare July 26, 2017 19:56
@googlebot

Copy link
Copy Markdown

So there's good news and bad news.

👍 The good news is that everyone that needs to sign a CLA (the pull request submitter and all commit authors) have done so. Everything is all good there.

😕 The bad news is that it appears that one or more commits were authored by someone other than the pull request submitter. We need to confirm that they're okay with their commits being contributed to this project. Please have them confirm that here in the pull request.

Note to project maintainer: This is a terminal state, meaning the cla/google commit status will not change from this state. It's up to you to confirm consent of the commit author(s) and merge this pull request when appropriate.

@vikerman

Copy link
Copy Markdown
Contributor

Does this have google3 impact?

@vicb

vicb commented Aug 11, 2017

Copy link
Copy Markdown
Contributor

closing as implemented in the new 5.x compiler flow - see #18494

@vicb vicb closed this Aug 11, 2017
@ocombe
ocombe deleted the feature-i18n-params-tsconfig-16232 branch November 10, 2017 08:48
@angular-automatic-lock-bot

Copy link
Copy Markdown

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.

@angular-automatic-lock-bot angular-automatic-lock-bot Bot locked and limited conversation to collaborators Sep 12, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area: i18n Issues related to localization and internationalization cla: no feature Label used to distinguish feature request from other issues state: blocked

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants