Skip to content

[IVY] i18n not working yet? #32311

Closed
Closed

Description

@spock123

I was trying out IVY on our medium sized corporate project - I finally managed to get the site compiled, but noticed none of the i18n translations were injected into the generated code.

Is i18n not supposed to work with IVY yet? Just curious

There are no error messages other than weird stuff like

WARNING in /Users/lrj/project/ivy2/src/app/modules/iticket-business/views/edit-profile/index.ts is part of the TypeScript compilation but it's unused.
Add only entry points to the 'files' or 'include' properties in your tsconfig.

But the site seems to be working - just not with the translations inserted.
I make heavy use of paths in tsconfig.json, - is this not supposed to be supported in IVY?

Is this a regression?

Don't know

🌍 Your Environment

Angular Version:


     _                      _                 ____ _     ___
    / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
   / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
  / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
 /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
                |___/
    

Angular CLI: 9.0.0-next.0
Node: 12.2.0
OS: darwin x64
Angular: 9.0.0-next.3
... animations, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router, service-worker

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.900.0-next.0
@angular-devkit/build-angular     0.900.0-next.0
@angular-devkit/build-optimizer   0.900.0-next.0
@angular-devkit/build-webpack     0.900.0-next.0
@angular-devkit/core              9.0.0-next.0
@angular-devkit/schematics        9.0.0-next.0
@angular/cdk                      8.1.2
@angular/cli                      9.0.0-next.0
@angular/material                 8.1.2
@angular/pwa                      0.900.0-next.0
@ngtools/webpack                  9.0.0-next.0
@schematics/angular               9.0.0-next.0
@schematics/update                0.900.0-next.0
rxjs                              6.5.2
typescript                        3.5.2

Anything else relevant?
I'm sorry if this is a dumb question but I just wanted to check if the i18n="@@my-id" was supposed to be working with IVY.

I make heavy use of paths in tsconfig.json, - is this not supposed to be supported in IVY?

Tsconfig:


{
  "compileOnSave": false,
  "angularCompilerOptions": {
    "enableIvy": true
  },
  "compilerOptions": {
    "baseUrl": "./src",
    "importHelpers": true,
    "outDir": "./dist/out-tsc",
    "sourceMap": true,
    "declaration": false,
    //"module": "es2015",
    "module": "esnext",
    "moduleResolution": "node",
    "noImplicitAny": false,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "target": "es5",
    "skipLibCheck": true,
    "typeRoots": [
      "node_modules/@types"
    ],
    "lib": [
      "es2018",
      "dom"
    ],
    "paths": {
      "@store/*": ["app/store/*", "app/store"],
      "@store": ["app/store/*", "app/store"],
      "@modules/*": ["app/modules/*", "app/modules"],
      "@modules": ["app/modules/*", "app/modules"],
      "@main/*": ["app/main/*", "app/main"],
      "@models/*": ["app/models/*", "app/models"],
      "@models": ["app/models/*", "app/models"],
      "@main": ["app/main/*", "app/main"],
      "@environment": ["environments/environment"],
      "@lib/*": ["app/lib/*", "app/lib"],
      "@lib": ["app/lib/*", "app/lib"],
      "@iticket-business/*": [ "app/modules/iticket-business/*", "app/modules/iticket-business"]
    }
  }
}

@ocombe

Activity

  1. spock123 commented on Aug 24, 2019

    @spock123
    Author

    Just for the record - the application works, except no translations are injected in the templates. Both during ng serve and production builds.

    Very strange

  2. ocombe commented on Aug 25, 2019

    @ocombe
    Contributor

    This looks more like an issue with angular cli than angular itself, because as far as I know translations work with ivy.
    I'm transferring the issue to the cli repository

  3. transferred this issue fromangular/angularon Aug 25, 2019
  4. alan-agius4 commented on Aug 25, 2019

    @alan-agius4
    Contributor

    @ocombe, did something change recently? AFAIK, the NGTSC compiler doesn’t support translations yet.

  5. ocombe commented on Aug 25, 2019

    @ocombe
    Contributor

    I thought that this was only for extracting, not loading them?

  6. alan-agius4 commented on Aug 25, 2019

    @alan-agius4
    Contributor

    Ngtsc doesn’t support loading the translations either.

  7. added this to the needsTriage milestone on Aug 25, 2019
  8. alan-agius4 commented on Aug 25, 2019

    @alan-agius4
    Contributor

    I had a chat with @alxhub about this in the past, and he was aware that this feature is not yet implemented in ngtsc.

  9. spock123 commented on Aug 25, 2019

    @spock123
    Author

    @AlabasterAxe @ocombe Ok thanks for the info guys.... We can close this issue then, it wasn't me going crazy hehe.... and stop working on a Sunday :)

  10. petebacondarwin commented on Aug 25, 2019

    @petebacondarwin
    Contributor

    What is the current process (pre-ivy) to load the translations? Is it to add them as a provider in the application root injector?

  11. ocombe commented on Aug 25, 2019

    @ocombe
    Contributor
  12. spock123 commented on Aug 25, 2019

    @spock123
    Author

    @ocombe yes that's also what I use in my project.. something like

     "da": {
                  "aot": true,
                  "i18nFile": "src/locale/messages.da.xlf",
                  "i18nFormat": "xlf",
                  "i18nLocale": "da",
                  "baseHref": "/da/",
                  "outputPath": "dist/da"
                },
    
  13. krassimir-nedelchev commented on Aug 25, 2019

    @krassimir-nedelchev

    Try this:

    • create a new file named "tsconfig.app.json" with next content:

    {
    "extends": "./tsconfig.json",
    "compilerOptions": {
    "outDir": "./out-tsc/app",
    "types": []
    },
    "files": [
    "src/main.ts",
    "src/polyfills.ts"
    ],
    "include": [
    "src//*.ts"
    ],
    "exclude": [
    "src/test.ts",
    "src/
    /*.spec.ts"
    ]
    }

    • save to the same directory as the "tsconfig.json" file;

    • edit angular.json and replace "tsConfig": "tsconfig.json" with "tsConfig": "tsconfig.app.json",

    Hope this helps...

  14. spock123 commented on Aug 25, 2019

    @spock123
    Author

    @krassimir-nedelchev Hi, thanks for your advice.

    I was already using the tsconfig.app.json file (but located in my src folder), I added the "files" and "include" sections but that didn't seem to help the issue with translations. No translations are added to the templates.

    HOWEVER they did remove all the warnings (
    ... is part of the TypeScript compilation but it's unused.)... so that's great! Thank you!

  15. krassimir-nedelchev commented on Aug 25, 2019

    @krassimir-nedelchev

    Or just append tsconfig.json with an exclude section:
    "exclude": [
    "src/app/modules/iticket-business/views/edit-profile/index.ts"
    ]

  16. kara commented on Aug 29, 2019

    @kara
    Contributor

    i18n work for Ivy is still in progress. @spock123 Closing this issue as it's not technically a bug or a feature request.

  17. spock123 commented on Aug 30, 2019

    @spock123
    Author

    @kara I accept that, just because it's you (star struck)

    On a serious note: thanks for clearing up the things.

  18. akash-gupt commented on Sep 4, 2019

    @akash-gupt

    any solution ?

  19. spock123 commented on Sep 4, 2019

    @spock123
    Author

    @techaks I guess we can just patiently await.. it definitely makes it impossible to try out Ivy if you use i18n.

  20. petebacondarwin commented on Sep 4, 2019

    @petebacondarwin
    Contributor

    We are working on i18n in ivy.

    We already have some pieces merged into master but it is not functional yet. There are a few more pieces to go and the plan is to have it all working by v9.0.0 release.

    Please bear with us.

  21. spock123 commented on Sep 4, 2019

    @spock123
    Author
  22. Javarome commented on Sep 20, 2019

    @Javarome

    Hi @ocombe @petebacondarwin
    I just upgraded to 9.0.0-next.7 to see if i18n was working better and actually found some changes that I... didn't expect: all <tag i18n="xxx">defaultValue</tag> are now displayed as <tag>:xxx:defaultValue</tag> without translation. Is it because this is old syntax and there is some new syntax I should use starting with next-7?

  23. petebacondarwin commented on Sep 23, 2019

    @petebacondarwin
    Contributor

    @Javarome did you also update your version of @angular/localize?

  24. angular-automatic-lock-bot commented on Oct 24, 2019

    @angular-automatic-lock-bot

    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.

  25. locked and limited conversation to collaborators on Oct 24, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: compilerIssues related to `ngc`, Angular's template compiler

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions