-
Notifications
You must be signed in to change notification settings - Fork 30
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
translate programmatically with Angular 2 #57
Comments
@magar91 I don't know, no change was made to the way I declare L in the global scope. |
@magar91 do you put |
I'm using the plugin with angular 2 but I didn't use |
@rborn I tried doing adding EDIT: I added the following import to my .ts file import * as application from "tns-core-modules/application"; and used the L() function like this application.getResources().L(value); I can use the L() function now inside my .ts class |
@magar91 Thank you |
@magar91 there are some replies in the NS ticket, could you give them a shot? |
@magar91 where did you do this? can it be done in the plugin? So it becomes seamless for other devs? |
I added it in the file where I used the function, here is an example of where I used it: import { Component, OnInit } from "@angular/core";
import { Item } from "./item";
import { ItemService } from "./item.service";
declare var global:any;
@Component({
selector: "ns-items",
moduleId: module.id,
templateUrl: "./items.component.html",
})
export class ItemsComponent implements OnInit {
items: Item[];
constructor(private itemService: ItemService) { }
ngOnInit(): void {
console.info(global.L("translate"))
this.items = this.itemService.getItems();
}
} to be honest I don't know if it can be done in the plugin, I'm sorry |
ok, thank you, I'll update the docs with your explanations 👍 |
anyone can help please "ERROR in ../node_modules/nativescript-i18n/angular.ts |
how can I call the L() function to translate programmatically inside of a .ts class component instead of an .html? I used to be able to do it with
global.L()
in previous versions of nativescript but with the new version 3.0.1 I can't use the global variable as I used toThe text was updated successfully, but these errors were encountered: