question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Trying to get aurelia-i18n running with typescript

See original GitHub issue

I’ve added this to aurelia.json

       {
            "name": "i18next",
            "path": "../node_modules/i18next/dist/umd",
            "main": "i18next"
          },
          {
            "name": "i18next-browser-languagedetector",
            "path": "../node_modules/i18next-browser-languagedetector/dist/umd",
            "main": "i18nextBrowserLanguageDetector"
          },
          {
            "name": "i18next-localstorage-cache",
            "path": "../node_modules/i18next-localstorage-cache/dist/umd",
            "main": "i18nextLocalStorageCache"
          },
          {
            "name": "i18next-xhr-backend",
            "path": "../node_modules/i18next-xhr-backend/dist/umd",
            "main": "i18nextXHRBackend"
          },
          {
            "name": "aurelia-i18n",
            "path": "../node_modules/aurelia-i18n/dist/amd",
            "main": "aurelia-i18n"
          }

however the package name specified in for instance i18next-xhr-backend is actually i18nextXHRBackend:

(function (global, factory) {
  typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
  typeof define === 'function' && define.amd ? define('i18nextBrowserLanguageDetector', factory) :
  (global.i18nextBrowserLanguageDetector = factory());
}(this, function () { 'use strict';

So these imports

import * as XHR from 'i18next-xhr-backend';
import * as Cache from 'i18next-localstorage-cache';
import * as LanguageDetector from 'i18next-browser-languagedetector';

import undefined since the package names don’t match.

If i change the imports to

import * as XHR from 'i18nextXHRBackend';

the tracer won’t find src/i18nextXHRBackend.js

If i change the declarations like:


                    {
            "name": "i18nextXHRBackend",
            "path": "../node_modules/i18next-xhr-backend/dist/umd",
            "main": "i18nextXHRBackend"
          },

the package analyser uses the wrong directory to try to find package.json “…/node_modules/i18nextXHRBackend/package.json”.

There doesn’t seem to be a way to change this behavior of using the name of the package to find the package.json file.

Is this an aurelia-thing (i18n, cli?) or an i18next thing? One way i can see this issue being resolved is to be able to override the path the analyser looks for package.json, but not sure if that is the most elegant way.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:10 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
len-rocommented, Aug 4, 2016

I managed to get the i18n working with the following: In aurelia.json

{
            "name": "aurelia-i18n",
            "path": "../node_modules/aurelia-i18n/dist/amd",
            "main": "index"
          },
          {
            "name": "i18next-xhr-backend",
            "path": "../node_modules/i18next-xhr-backend/dist/umd",
            "main": "i18nextXHRBackend"
          },
          {
            "name": "i18next",
            "path": "../node_modules/i18next/dist/umd",
            "main": "i18next"
          }

added typings as decribed here: https://github.com/aurelia/i18n

in code:

import { I18N } from 'aurelia-i18n';
import * as XHR from 'i18next-xhr-backend';
0reactions
JeroenVinkecommented, Feb 24, 2017

The instructions provided by @len-ro seem to be described in the docs now

Read more comments on GitHub >

github_iconTop Results From Across the Web

I18N | Aurelia
This documentation explains how to get up and running with Aurelia-I18N in order to provide localization and internationalization features with your app.
Read more >
Aurelia-i18n + Typescript 2.3.0 Setup - Stack Overflow
I am trying to use aurelia-i18n in my project where i use Typescript 2.3 and webpack (no aurelia-cli). I have installed so far...
Read more >
Developers - Trying to get aurelia-i18n running with typescript -
Coming soon: A brand new website interface for an even better experience!
Read more >
aurelia-i18n - npm
Start using aurelia-i18n in your project by running `npm i aurelia-i18n`. There are 21 other projects in the npm registry using ...
Read more >
Translating Aurelia applications with Aurelia i18n - Lokalise Blog
Not only that, but you can also use an extensive ecosystem full of various packages. No matter whether you use JavaScript or TypeScript,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found