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

Problem with importing/compiling i18n and Backend in skeleton project #136

Closed
don-bluelinegrid opened this issue Jul 21, 2016 · 12 comments
Closed
Labels

Comments

@don-bluelinegrid
Copy link

I'm submitting a bug report

  • Library Version:
    1.0.0-rc.1.0.0

Please tell us about your environment:

  • Operating System:
    OSX 10.11.5
  • Node Version:
    v4.4.7
  • NPM Version:
    3.10.3
  • JSPM OR Webpack AND Version
  • Browser:
  • Language:
    TypeScript

Current behavior:

I am new to Aurelia, setting up an environment for a new commercial product project. When I follow the aurelia-i18n ReadMe, I get the following problems:

  1. Typescript compilation problem Informations about this plugin #1, with no additions to tsconfig.json:

ERROR in [default] /Users/donpeterkofsky/Documents/gc-2/typings/globals/i18next-xhr-backend.d.ts:22:29
Generic type 'Array' requires 1 type argument(s).

ERROR in [default] /Users/donpeterkofsky/Documents/gc-2/typings/globals/i18next-xhr-backend.d.ts:22:48

Generic type 'Array' requires 1 type argument(s).

  1. Typescript compilation problem What is the purpose/status of this repository? #2, with the recommended additions to tsconfig.json, i.e., added this -

    "filesGlob": [
    "./typings/browser.d.ts", // this must be specified in case you use typings(https://github.com/typings/typings)
    "./typings/*/.d.ts" // if you use both typings files from this repository (doc/*.d.ts)
    ]

  • which then results in this error:

ERROR in [default] /Users/donpeterkofsky/Documents/gc-2/node_modules/aurelia-fetch-client/dist/aurelia-fetch-client.d.ts:73:42
Cannot find name 'URLSearchParams'.

ERROR in [default] /Users/donpeterkofsky/Documents/gc-2/src/login.ts:12:28
Cannot find name 'System'.

ERROR in [default] /Users/donpeterkofsky/Documents/gc-2/src/users.ts:10:28
Cannot find name 'System'.

ERROR in [default] /Users/donpeterkofsky/Documents/gc-2/typings/globals/118next/i18next-xhr-backend.d.ts:22:29
Generic type 'Array' requires 1 type argument(s).

ERROR in [default] /Users/donpeterkofsky/Documents/gc-2/typings/globals/118next/i18next-xhr-backend.d.ts:22:48

Generic type 'Array' requires 1 type argument(s).

I copied the type definition files from the i18next GitHub, 2.0.0 branch.

The above errors are seen without even including import statements in my code like:

import * as I18N from 'aurelia-i18n';
import * as Backend from 'i18next-xhr-backend';

Is there something else I've missed, or any suggestions for resolving this?

Thanks.

@don-bluelinegrid
Copy link
Author

UPDATE**

I am new to Aurelia, but am not new to JavaScript or JS frameworks. What I've done is to first install the Aurelia skeleton project for Typescript-Webpack, and then install the aurelia-i18n package according to its README. Then, I saw the compilation errors I posted above.

I then spent several days trying to discover what was necessary to eliminate the errors, by reading some obscure bug reports in the underlying i18n project on GitHub. Eventually, by manually downloading/copying some typings files, and trial and error of determining where to place the files, I have eliminated the initial compilation problem that was triggered by importing the 'aurelia-i18n' package. The compilerOptions notes posted above were not the solution.

However, when I try to set the configuration in the Aurelia main.ts file, using this code -

[code]
.plugin('aurelia-i18n', (instance) => {
// Import i18n resources.

    // // register backend plugin
    // instance.i18next.use(Backend);

    // adapt options to your needs (see http://i18next.com/docs/options/)
    // make sure to return the promise of the setup method, in order to guarantee proper loading
    return instance.setup({
      // backend: {                                  // <-- configure backend settings
      //   loadPath: '/locales/{{lng}}/{{ns}}.json', // <-- XHR settings for where to get the files from
      // },
      // resources: ,
        resources: {
        en: {
          translation: {
            "key": "hello world"
          }
        }
      },
      lng : 'de',
      attributes : ['t','i18n'],
      fallbackLng : 'en',
      debug : false
    });
  });

[/code]

  • there are multiple problems.

First, I get an error in the JS console that the aurelia-i18n package can't be found, triggered by the code .plugin('aurelia-i18n', (instance):

DEBUG [aurelia] Loading plugin aurelia-i18n.
.$:85Uncaught (in promise) Error: Cannot find module './aurelia-i18n'.(…)
webpackContextResolve @ .
$:85
webpackContext @ .*$:80
(anonymous function) @ aurelia-loader-webpack.js:104
webpack-dev-server.js:2
[WDS] Errors while compiling.

Second, if I then add the import for the xhr-backend, with either of these -
import Backend from 'i18next-xhr-backend';
import * as Backend from 'i18next-xhr-backend';

  • my editor is showing an error of "Cannot find module 'i18next-xhr-backend' ".

Again, I've followed the instructions exactly in the various READMEs, and started with the Aurelia-provided skeleton project.

Once again, any help or solutions are appreciated.

Thanks,
Don

@gravsten
Copy link

I am having a similar problem with a TypeScript project. Was working until I installed aurelia-i18n following the instructions.

Now, build fails with the error message:
main.ts(2,20): error TS2307: Cannot find module 'aurelia-i18n'.
main.ts(3,21): error TS2307: Cannot find module 'i18next-xhr-backend'.

If you find a solution, please let us know.

Full disclosure: I hit a previous problem introduced by aurelia-i18n, which I resolved with a simple change to .\typings\modules\aurelia-validatejs\index.d.ts :
import validate from 'validate.js';
->
import * as validate from 'validate.js';

@Ullfis
Copy link

Ullfis commented Aug 19, 2016

Her is an working typescript-webpack project with aurelia-i18n:

https://github.com/Ullfis/i18n-aurelia-typescript-webpack

Typings used (custom_typings/custom.d.ts):

/// <reference path="../node_modules/aurelia-i18n/doc/i18next.d.ts" />
/// <reference path="../node_modules/i18next-xhr-backend/typings/i18next-xhr-backend.d.ts" />

@don-bluelinegrid
Copy link
Author

After updating to aurelia-18n v1.1.1, this is now failing:

default] Checking started in a separate process...
[default] /Users/donpeterkofsky/Documents/gc-2/node_modules/aurelia-i18n/dist/aurelia-i18n.d.ts:42:33 
    Cannot find namespace 'i18next'.
[default] /Users/donpeterkofsky/Documents/gc-2/node_modules/aurelia-i18n/dist/aurelia-i18n.d.ts:43:27 
    Cannot find namespace 'i18next'.

@zewa666
Copy link
Member

zewa666 commented Aug 30, 2016

Can you somehow create a zip or upload your example to github, excluding the jspm/node folder, so that we can try to replicate your issue?

@don-bluelinegrid
Copy link
Author

@zewa666

As noted here:
aurelia/skeleton-navigation#628 (comment)

and here:
#136 (comment)

This happens with the out-of-the-box typescript-webpack skeleton, as soon as the aurelia-i18n module is added.
typescript-webpack skeleton = works
typescript-webpack skeleton + aurelia-i18n = shows the build error

There is no need for creating a special repository, this can be reproduced by using the skeleton + i18n.

The previously-suggested change for typings noted above (#136 (comment)) worked when using aurelia-i18n@1.0.0. Yesterday, I upgraded to aurelia-i18n@1.1.0, and I started seeing the error:

default] Checking started in a separate process...
[default] /Users/donpeterkofsky/Documents/gc-2/node_modules/aurelia-i18n/dist/aurelia-i18n.d.ts:42:33 
    Cannot find namespace 'i18next'.
[default] /Users/donpeterkofsky/Documents/gc-2/node_modules/aurelia-i18n/dist/aurelia-i18n.d.ts:43:27 
    Cannot find namespace 'i18next'.

@don-bluelinegrid
Copy link
Author

@zewa666

Also please note: aurelia/skeleton-navigation#628 (comment)

@don-bluelinegrid
Copy link
Author

don-bluelinegrid commented Aug 30, 2016

Seems to be related to changes from these lines of dist/aurelia-i18n.d.ts:

 -  setup(options?: any): any;
 -  i18nextReady(): any;

to this:

 +  setup(options?: any): Promise<i18next.I18n>;
 +  i18nextReady(): Promise<i18next.I18n>;

which are now making reference to a type of i18next.I18n. However, it looks like i18next is declared like so:

i18next: any;

Is this correct?

@zewa666
Copy link
Member

zewa666 commented Aug 30, 2016

Did I mention already that I hate TypeScript? :)
Gonna revert that, it seems it was overambitious to add those types.

@don-bluelinegrid
Copy link
Author

@zewa666

Thank you.

Please post a comment when this is fixed, as it has currently broken my application, preventing it from running.

Thanks,
Don

zewa666 added a commit that referenced this issue Aug 30, 2016
fixes wrong return type information of setup and i18nextReady methods

fixes issue #136 (comment)
@zewa666
Copy link
Member

zewa666 commented Aug 30, 2016

@don-bluelinegrid I'm sorry about that. I've already pushed the fix, just want to wait to include the active PR and will get a patch release out.

@don-bluelinegrid
Copy link
Author

@zewa666

Thanks.

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

No branches or pull requests

5 participants