Giter Site home page Giter Site logo

danvick / ngx-translate-nativescript-loader Goto Github PK

View Code? Open in Web Editor NEW
7.0 7.0 3.0 50 KB

A loader for `ngx-translate` internationalization library that loads locally stored translations for NativeScript Angular.

Home Page: https://www.npmjs.com/package/@danvick/ngx-translate-nativescript-loader

JavaScript 10.96% TypeScript 89.04%

ngx-translate-nativescript-loader's Introduction

Hi ๐Ÿ‘‹, I'm Danvick

A passionate full-stack and Flutter developer based in Nairobi

danvick

danvick

danvickmiller

Blogs posts

Connect with me:

danvick danvickmiller 2949916 @danvickmiller

Languages and Tools:

bash dart docker firebase flutter grafana ionic java javascript mariadb mongodb mysql nativescript php postman sqlite typescript

Support:

danvick



ยท

danvickย  danvickย  danvick

ngx-translate-nativescript-loader's People

Contributors

danvick avatar dependabot[bot] avatar hrueger avatar jamescodesthings avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

ngx-translate-nativescript-loader's Issues

Cannot use in Angular 6

Awesome plugin! I have some problem when applied it to Angular 6. Anyone can advice how to handle this?

ERROR in ../node_modules/rxjs/observable/fromPromise.js
Module not found: Error: Can't resolve 'rxjs-compat/observable/fromPromise' in '/Users/fongleansing/Sites/IOS/delivereat-app/node_modules/rxjs/observable'
 @ ../node_modules/rxjs/observable/fromPromise.js 6:9-54
 @ ../node_modules/@danvick/ngx-translate-nativescript-loader/dist/index.js
 @ ./app.module.ts
 @ ./main.ts

Support for Angular 12 / NativeScript 8

I am using this (awesome) plugin in a few apps which I migrated to NativeScript 8 recently. On npm install I get the following dependency warnings on my Angular 12/NativeScript 8 apps:

npm WARN @danvick/[email protected] requires a peer of @angular/common@^11.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN @danvick/[email protected] requires a peer of @angular/core@^11.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN @danvick/[email protected] requires a peer of @nativescript/angular@^11.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN @danvick/[email protected] requires a peer of @nativescript/core@^7.0.0 but none is installed. You must install peer dependencies yourself.

The plugin seems to work fine though.
Do you have any plans on officially supporting NativeScript 8 and Angular 12? I would highly appreciate it :)

support for angular 9 and 10

I am using this library in my project and I keep getting these npm warnings:

npm WARN @danvick/[email protected] requires a peer of @angular/core@>= 6.0.0 < 7.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN @danvick/[email protected] requires a peer of @angular/common@>= 6.0.0 < 7.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN @danvick/[email protected] requires a peer of @ngx-translate/core@^9.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN @danvick/[email protected] requires a peer of nativescript-angular@>= 6.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN @danvick/[email protected] requires a peer of tns-core-modules@^4.0.0 but none is installed. You must install peer dependencies yourself.

Can you please update the plugin to support the latest versions of Angular?

JS: ERROR SyntaxError: Unexpected end of JSON input

I'm writing an app with NativeScript 6.4.1 and Angular 8.

I followed the instructions on the readme file to install this plugin and I keep getting an error.

Here is my repository: https://github.com/aubrey-fowler/translationsTest1

I ran:

npm i @ngx-translate/core --save
npm i @danvick/ngx-translate-nativescript-loader --save

code snippet:

export function createTranslateLoader() {
    return new NativeScriptLoader("./assets/i18n/", ".json");
}

@NgModule({
    bootstrap: [
        AppComponent
    ],
    imports: [
        NativeScriptHttpClientModule,
        NativeScriptFormsModule,
        NativeScriptModule,
        AppRoutingModule,
        TranslateModule.forRoot({
            loader: {
                provide: TranslateLoader,
                useFactory: createTranslateLoader
              }
          })
    ],

Here is my error at runtime:

Webpack compilation complete. Watching for file changes.
Webpack build done!
Successfully transferred bundle.91f370336d7ada04715a.hot-update.js on device emulator-5554.
Successfully transferred 91f370336d7ada04715a.hot-update.json on device emulator-5554.
JS: HMR: Checking for updates to the bundle with hmr hash 91f370336d7ada04715a.
JS: HMR: The following modules were updated:
JS: HMR:          โ†ป ./app/app.module.ts
JS: HMR: Successfully applied update with hmr hash 91f370336d7ada04715a. App is up to date.
Refreshing application on device emulator-5554...
JS: Angular is running in the development mode. Call enableProdMode() to enable the production mode.
JS: ERROR SyntaxError: Unexpected end of JSON input
Successfully synced application org.nativescript.translationsTest1 on device emulator-5554.
JS: ERROR SyntaxError: Unexpected end of JSON input

Assumed options as stated in Readme don't work

In the readme file you say, that default options are assumed:

The assumed default location for your translation is ./assets/i18n/ and default assumed format extesion is .json.

However, this does not work. By adding a console.log to the .js file in my node modules folder like so:

NativeScriptLoader.prototype.getTranslation = function(lang) {
        console.log(file_system_1.knownFolders.currentApp().getFile("" + this.prefix + lang + this.suffix));
        return rxjs_1.from(file_system_1.knownFolders.currentApp().getFile("" + this.prefix + lang + this.suffix).readText()).pipe(operators_1.map(function(data) { return JSON.parse(data); }));
    };

I see, that the file path for the de language is

JS: {
JS:   "_path": "/data/data/com.schoolsquirrel.SchoolSquirrel/files/app/undefineddeundefined",
JS:   "_name": "undefineddeundefined",
JS:   "_extension": ".SchoolSquirrel/files/app/undefineddeundefined"JS: }

It uses undefined for praefix and suffix.

I believe because here the attributes are overwritten with undefined.

It's not a big problem, the library itself is working great! It just cost me quite some time to figure out why it is not working.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.