Comments (11)
You should either use [title]="'HELLO' | translate"
or title="{{ 'HELLO' | translate }}"
, but [title]="{{ 'HELLO' | translate }}"
is not correct Angular
from core.
You're supposed to use your key, something like that:
<ion-refresher pullingText="{{ 'PULL' | translate }}">
And then you define the translation in your json file (or you manually) like that: "PULL": "Pull to refresh..."
In this case "PULL" is the key, and "Pull to refresh..." is your translation.
from core.
fetchTranslation(key: string, params = {}) {
return this.translate.instant(key, params);
}
or you could just use the service:
[title]="translate.instant('HELLO')"
But be careful because if you use the change detection OnPush this will not update your view, you should use the pipe or directive for that.
from core.
no, it's in the docs: https://github.com/ngx-translate/core#methods
from core.
I apologise, this was an error triggered by some other issue.
from core.
@ocombe it also works with hardcoded string.
from core.
What if we have the HTML attribute tied to a component property? For example...
[title]="{{ 'HELLO' | translate }}"
Or even using a method like this in the component doesn't work for me. It just puts undefined in the view:
[title]="fetchTranslation('HELLO')"
fetchTranslation(key: string, params = {}) {
this.translate.get(key, params).subscribe((res: string) => {
return res;
});
}
from core.
Got it. Thanks for the quick reply! :) any idea how to get the service thing working though? That would really help with keeping the views tidy.
from core.
Worked like a charm! Thank you 👍
By the way, is there any extra documentation available? Like would I have needed to read the source to find out about that method?
from core.
I have the above working, but I become stuck when using data-title on tables.
data-title="{{fetchTranslation('name')}}"
for example does not work.
Is there a was to get this working with data-title? This is a key property for displaying data on mobile.
from core.
I had this problem,
[title]="'Location' | translate"
shows a tool-tip
but,
[title]="'Historical Development' | translate"
does not show a tool-tip
same for
title="{{ 'Historical Development' | translate}}"
but when I remove the translate pipe -
title="'Historical Development'"
does show a tool-tip
from core.
Related Issues (20)
- setTranslation is confusing the translation
- bump angular 17 HOT 3
- Translation keys are ignored when dot format and nested format are mixed
- How to handle import TranslateModule.forChild in module when creating a standalone component in an NgModule Application HOT 8
- How to use ngx-translate in Angular 17, Knowing that AppModule is not implemented? HOT 2
- Support for Angular v17 HOT 28
- ngx-translate creates billions of tiny files HOT 1
- Using ngx-translate in a standalone component HOT 3
- 'EventEmitter' and 'DefaultLangChangeEvent' is declared but its value is never read.
- Angular 17 SSR. Standalone implementation - NullInjectorError: No provider for _TranslatePipe! HOT 1
- I am trying to add Arabic language. I have configured package correctly but some labels are translated some are not
- Latency when loading the website, because Translation Key appears when user opens our website HOT 1
- Add opption to pass callback in translate pipe
- ncaught SyntaxError: Cannot use import statement outside a module (at scripts.js:16887:1) main.ts:13 Error: Unexpected value 'TranslateModule' imported by the module 'AppModule'. Please add an @NgModule annotation. at verifySemanticsOfNgModuleDef (core.mjs:28868:5) at core.mjs:28878:5 at Array.forEach (<anonymous>) at verifySemanticsOfNgModuleDef (core.mjs:28876:43) at AppModule.get (core.mjs:28833:23) at getInjectorDef (core.mjs:333:1) at walkProviderTree (core.mjs:5550:1) at core.mjs:5500:6 at core.mjs:4701:1 at Array.forEach (<anonymous>)
- Wrong TranslateHttpLoader after upgrade app to Angular 17
- ngx-translate not working with interceptor in Ionic Capacitor app
- Error: [$injector:unpr] Unknown provider: translateProvider <- translate
- Configuration: defaultLanguage in TranslateModule.forRoot as a Provider HOT 1
- ngx-translate.com is pointing another website HOT 3
- Ngx-translate: ..assets/i18n/ja.json: 404 Not Found after deployment
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from core.