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

[i18n] future 2.x plan #9104

Closed
13 of 21 tasks
vicb opened this issue Jun 8, 2016 · 122 comments
Closed
13 of 21 tasks

[i18n] future 2.x plan #9104

vicb opened this issue Jun 8, 2016 · 122 comments
Assignees

Comments

@vicb
Copy link
Contributor

vicb commented Jun 8, 2016

Features planned for 2.0:

  • gender
  • pluralization
  • runtime compiler
  • offline compiler
  • xliff support
  • hash message ids
  • i18n messages

fix issues:

fix post 2.0:

@thelgevold
Copy link
Contributor

@vicb I have seen a few postings about i18n in the angular repo. How does this relate to https://github.com/angular/i18n? Is this a new initiative?

@robwormald
Copy link
Contributor

@thelgevold like most things in ng2, the standalone repos existed for early prototyping. major work is typically done inside of this one.

@vicb vicb added this to the Angular 2 Final milestone Jun 9, 2016
@vicb vicb added the area: i18n label Jun 9, 2016
@marcalj
Copy link

marcalj commented Jun 10, 2016

Hi, there's any document about how it will work?
I'm wondering if I can write keys in markup and normal text in translation files like I'm using with angular-translate.

{{ 'HOMEPAGE__ACTION__SIGNUP' | translate }}

Coding like this, one external person can edit all supported languages (since they reside in JSON/po file, one file per language). If the main language is in the markup, it blocks all revisions until a developer can change the string in the markup code.

Thanks!

@vicb
Copy link
Contributor Author

vicb commented Jun 10, 2016

@marcalj The (outdated) spec is https://docs.google.com/document/d/1mwyOFsAD-bPoXTk3Hthq0CAcGXCUw-BtTJMR4nGTY-0/edit.

Your use case is supported.

@marcalj
Copy link

marcalj commented Jun 11, 2016

Thanks Victor! Any plans to include number abbreviations? It's something i18n context aware.

@vicb
Copy link
Contributor Author

vicb commented Jun 16, 2016

@marcalj could you please create a separate issue with more details ? Thanks (but probably not for 2.0 anyways)

@vicb vicb self-assigned this Jun 23, 2016
@dagerber
Copy link

Is or will there be support for dynamic translations (loaded from a server)?
Any plans to document i18n in the near future?
Thanks!

@vicb
Copy link
Contributor Author

vicb commented Jun 24, 2016

The current plan is to generate a binary per locale.

We will work on the doc as the features become available. We should definitely have a minimal doc for the 2.0 release.

@jaska45
Copy link

jaska45 commented Jul 1, 2016

What do you mean by "binary per locale". Is the deployed resource file going to be binary little bit like PO/MO where MO is used insted of PO to improve performance. There are also bad examples in binary deployment such as XAML/BAML.

I am not very happy to the current Anguar localization methods. These are the reasons:

  • Several different APIs and methods.
  • You have to modify your templates so much from original that templates become hard to read and maintain.
  • You have to manually update the original resource file and make sure it is in sync with the IDs used in the template

What we really need is

  • One single official localization method with solid resource format (XML or JSON based)
  • Minimal affect to templates. For example only add "localize" attribute into root element and possible "noloc" attributes into those elements that are not localized.
  • Ability to add localization comments to the strings in the templates.
  • A tool that scans source code extracting orignal strings and comments into resource file. Use as permanent ids as possible. For example use id attributes or if such is not provided use combination of location and original string value.
  • This resource file should be able to store plain strings, strings with patterns ({{...}}), pluralized strings and gender strings little bit like Android's value files.
  • Easy way to package localized resources and to download them as needed
  • Ability to change language without reload.

I am ready to help if you guys need some help.

@vicb
Copy link
Contributor Author

vicb commented Jul 1, 2016

@jaska45 most your wishes should come true. One exception: "Ability to change language without reload.". Changing a language will imply bootstrapping a new app.

@jaska45
Copy link

jaska45 commented Jul 1, 2016

Thanks. Sound very good. Language change is something that occurs seldom and in that case it is acceptable that some state is lost. Definetely lowest priority in my list and not worth spending too much efforts.

@choeller
Copy link
Contributor

choeller commented Jul 4, 2016

@vicb I'm not sure if I understand this "binary per locale" correctly, but would that mean, that it's not possible to add translations at runtime? We are currently building SAAS with tenant support, where each tenant can extend our system by providing their own set of Form-Definitions and their own set of translations, so in our case it would be really important to be able to add translations at runtime.

@nickspoons
Copy link

The @angular/common DatePipe (date_pipe.ts) currently contains this TODO on line 15:

// TODO: move to a global configurable location along with other i18n components.
var defaultLocale: string = 'en-US';

Is the ability to pass in a locale string to the DatePipe included in the i18n plans for the 2.0 release?

@marcalj
Copy link

marcalj commented Jul 5, 2016

@vicb Our app sets the frontend language once we fetch user object from network after bootstrapping the application. So, did you define if this process of re-boostrapping would be easy?

@vicb vicb mentioned this issue Jul 29, 2016
@MrCroft
Copy link

MrCroft commented Aug 3, 2016

There's one bit of information I can't find anywhere, just to confirm and be able to sleep at night :)
The official i18n implementation will support gettext/po files, right? That's very common, so I'm guessing it should be available, we won't be stuck with jsons and xtb only, am I right? I mean gettext is so common that it doesn't even need mentioning, it's always there out of the box in any i18n implementation, that's what I'm thinking.

@vicb
Copy link
Contributor Author

vicb commented Aug 4, 2016

There is no plan to support po for 2.0. You should be able to convert from/to xliff.

sorry for your nights !

@intellix
Copy link

intellix commented Aug 4, 2016

What's the thought behind storing strings in XML format? Never ran into any issues extracting to POT and compiling PO to JSON in angular-gettext. It's served us extremely well:

// en-GB.json, cached into localStorage after first request
"en-GB": {
    "Hello {{firstName}}": "{{firstName}}, Gutentag"
}

Random question: any thoughts about translated URLs in the router?

@vicb
Copy link
Contributor Author

vicb commented Aug 4, 2016

Random question: any thoughts about translated URLs in the router?

@vsavkin what are the plans ?

@vsavkin
Copy link
Contributor

vsavkin commented Aug 5, 2016

We are not planning to provide any support for translated URLs until the final is out. We had some ideas on ways to do that after that, but we haven't made any decisions.

@concept-hf
Copy link

ng2 i18n gave me a headache. I was looking for i18n directive in exports :D to no end... Looking through the test specs, and code the lightning struck me:

The template compiler itself will transform and localize the template.

Am I right, that the basic workflow for i18n will be like this:

  1. Mark elements with i18n or enclose html parts in i18n comments.
  2. Run somehow the extractor (ng cli?) to produce xliff.
  3. Pass that to translation and receive back the translated binary.
  4. Configure angular at bootstrap somehow to use the wanted language binary file.
  5. The template compiler itself will transform and localize the template.

Because if it is, for the time being I will use a custom "i18n" directive to mimic the very-very basics of translation until 2.0 hits.

Is this the intended workflow for i18n in angular2 in the future?

@vicb
Copy link
Contributor Author

vicb commented Aug 8, 2016

@concept-hf that is right, see the doc that I linker earlier in this discussion.

You'll run ng-xi18n to create the xliff.

We have a couple of directives and filter for ICU messages

@marcalj
Copy link

marcalj commented Aug 8, 2016

@vicb Will be available in the upcoming RC5? :)

@vicb
Copy link
Contributor Author

vicb commented Aug 8, 2016

Depends on when RC5 is... otherwise will be in RC6

@esinek
Copy link

esinek commented Aug 9, 2016

What version of XLIFF will be supported? 1.2 or 2.0 or both?

@ghidoz
Copy link

ghidoz commented Dec 14, 2016

I found a problem with plurals and select: are you sure it is correctly implemented?

If I have just normal string, I can export them with the ng-xi18n command, but if I add a string with plurals or select, it does not work.

Using

<span i18n>{user.receivedReports, plural, =0 {No spam/scam reports} =1 {One spam/scam report} other {# spam/scam reports}}</span>

and

<span i18n>{currentConversation.user.online, select, true {Online} false {Offline}}</span>

I get many parsing errors like this:

Unexpected closing tag "li" ("plural, =0 {No spam/scam reports} =1 {One spam/scam report} other {# spam/scam reports}}</span>
    [ERROR ->]</li>

Using the comments syntax I get no error while extracting:

<!--i18n: select test-->
{user.online, select, true {Online} false {Offline}}
<!--/i18n-->
<!--i18n: plural test-->
{user.receivedReports, plural, =0 {No spam/scam reports} =1 {One spam/scam report} other {# spam/scam reports}}
<!--/i18n-->

but then what I get in the XLF file is just empty tags:

<trans-unit id="2b10577df0a3d78b7e65c07d5760524f881f390a" datatype="html">
    <source>
        <x id="ICU"/>
    </source>
    <target/>
    <note priority="1" from="description">plural test</note>
</trans-unit>

<trans-unit id="e61681024eadd7f72e33f053f04c128910c419a2" datatype="html">
    <source>
        <x id="ICU"/>
    </source>
    <target/>
    <note priority="1" from="description">select test</note>
</trans-unit>

I am doing something wrong?

Edit: using --i18nFormat=xmb throws the same error using the attribute version, while it seems to work with the comment version:

<msg id="3c8aef599bb96e303600aa44617acd0a7d602147">{user.receivedReports, plural, =0 {No spam/scam reports} =1 {One spam/scam report} other {# spam/scam reports} }</msg>
<msg id="06fe711b55463e3ee28d72239d77e9a50da62d86">{currentConversation.user.online, select, true {Online} false {Offline} }</msg> 

@zh99998
Copy link

zh99998 commented Jan 4, 2017

how to translate Date/Time ?

@martinmcwhorter
Copy link

martinmcwhorter commented Jan 4, 2017 via email

@dietergeerts
Copy link

@feloy , your example only let's you switch the lang on the login page, what if you want to switch the lang when logged in, and without a browser refresh? How to manually destroy the application and bootstrap it again?

@rolandoldengarm
Copy link

@dietergeerts that's only possible with JIT, not with AOT.

@dietergeerts
Copy link

@rolandoldengarm , it's also possible with AOT if you load your translations on application load. I'm currently using something in between ngx-translate and the official i18n, in the sense that we use pipes to get the translations (pure ones), but we only load one language at startup, and switching the language requires a reboot of the application (If only we had routing reload, as the i18n setup is done in one of the root resolves)

@Thomas-Kuipers
Copy link

@vicb

I'll try to take a look at what's needed e/o this week and come with a plan.

Do you have any updates on the roadmap? Specifically for an i18n implementation for translations outside of templates.

@thelgevold
Copy link
Contributor

I am also very interested in the capability to translate strings in TypeScript. Any ETA on this?

usernamealreadyis referenced this issue in GistIcon/angular Mar 3, 2017
For custom Cucumber steps, you should generate a file using the JUnit formatter and write it to the $CIRCLE_TEST_REPORTS/cucumber directory
usernamealreadyis referenced this issue in GistIcon/angular Mar 3, 2017
new(text, old_name, new_name, comment, singleton = false)
Creates a new Alias with a token stream of text that aliases old_name to new_name, has comment and is a singleton context.
@ocombe
Copy link
Contributor

ocombe commented Mar 16, 2017

@Thomas-Kuipers @thelgevold I'm working on it, and it will be available in 4.1 or 4.2 (most likely)

@rayer4u
Copy link

rayer4u commented Mar 21, 2017

@ocombe
how to deal with static text in interpolation, which can't use select translation.

<div i18n>{{exercise._desc ? exercise._desc : 'empty'}}</div>

string 'empty' can't be translate

@ocombe
Copy link
Contributor

ocombe commented Mar 21, 2017

@rayer4u this is not the subject of this issue, for support questions you should use stackoverflow or gitter.
I'll answer this one anyway, but don't ask further questions here that are unrelated to i18n future plans please.

The answer is: you can't do it, dynamic translations are not supported by Angular i18n since it works at compile or build time, and not at runtime.

@martinmcwhorter
Copy link

Off Topic: I Apologize
@rayer4u The solution is to use static translations:

<div *ngIf="exercise?._desc">{{ exercise?._desc }}</div>
<div *ngIf="!exercise?._desc" i18n>empty</div>

@rayer4u
Copy link

rayer4u commented Mar 22, 2017

@ocombe I Apologize for off Topic, no need to reply. I just have this need and can't find any quick way to discuss it. I think this may be concerned by angular i18n plan. As Angular i18n plan don't deal with interpolation, a extra mark/find/replace is better build time i18n solution for me right now.
@martinmcwhorter Thanks for your reply. We write a lot mixed if/else logic to output diffrent i18n text in template, this is the easiest one. Maybe put runtime text logic in template is a bad choice.

@elvisbegovic
Copy link
Contributor

maybe this is bad idea but can't angular add automatically @@id in our i18n attributes when we extract first time ?

@ocombe
Copy link
Contributor

ocombe commented Mar 29, 2017

No because we would have to maintain this when you edit the code.
Let's say that you have two blocks of i18n code that are the same, we add the ids, and then you change one of them, the ids don't match which means that the next extraction will skip on of those...

@elvisbegovic
Copy link
Contributor

elvisbegovic commented Mar 29, 2017

I confirm it's bad idea, can you explain how angular know to attribut same id to string when we extract again and again, how they keep same ID on string. so powerful but I don't undersand :s

@ocombe

@ocombe
Copy link
Contributor

ocombe commented Mar 29, 2017

This is what we use: https://github.com/angular/angular/blob/master/packages/compiler/src/i18n/digest.ts#L13-L15

@ocombe
Copy link
Contributor

ocombe commented May 2, 2017

We are now at v4 so I'm closing this issue, please follow up in #16477 for our plans for v4 and beyond.

@ocombe ocombe closed this as completed May 2, 2017
@angular-automatic-lock-bot
Copy link

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 11, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests