core
core copied to clipboard
Next release
Hello, i would like to know when the next release is planned ? Because i'm currently facing an issue with setDefaultLang and the modifications in this commit (https://github.com/ngx-translate/core/commit/610e4f146d748af78cefc523ff323b49688bff68) seems to be what i need to fix my issue. (setDefaultLang returning an observable instead of void)
(FI: My issue is that the default language is not set because the "pending" observable is not resolved when i call translateService.instant)
As I couldn't wait either, I made a release of the current state of this repo, as @wamasimba/ngx-translate-core, version 16.0.5
See https://www.npmjs.com/package/@wamasimba/ngx-translate-core
Hey @UrzaUrza.
We've prepared an RC: https://www.npmjs.com/package/@ngx-translate/core/v/16.1.0-rc.0 Feel free to use it and give us feedback if it works or not for you : )
@CodeAndWeb I found the following, but I'm wondering if this is due to it being the release candidate.
I imported it locally and it seems to be working just fine. So you have my green light
Hello @rbalet,
This version is fixing my issue but:
- The package @ngx-translate/[email protected] deployed on npm has not been built correctly (I built it locally for testing), which is why you got errors on the import
- The field "translation" of the "TranslateService" has been removed (breaking change), so for replacement I decided to use the "getTranslations" method of the "TranslateStore" but the type "DeepReadonly" is not exposed (I redefined it locally for the test) and should be.
@UrzaUrza
- same happened to me
- For this one I'm not sure of the reason behind the depreciation, and IMO the store shouldn't be accessed directly
- I know @CodeAndWeb which have the right to publish to be a bit overwhelmed at the moment, you'll need to be patient
@CodeAndWeb what is your take on it? (For the depracation? And do you have an idea on the when we could deliver a new version ?
@UrzaUrza The v16.1.0-rc.1 is ready to be tested. Would you have time to test it on your end ?
@CodeAndWeb I just find one changes that was breaking my code.
export type InterpolationParameters = Record<string, unknown>;
It does not let me pass an object that does already have a strong type.
I googled but I'm not sure on the reason why...
Step to reproduce
Open the core project, and past into the app.component.ts file the following code
import { Component, inject, OnInit } from "@angular/core";
import { _, TranslateDirective, TranslatePipe, TranslateService } from "@ngx-translate/core";
import { map } from "rxjs";
import { TranslationObject } from "../../../ngx-translate/src/public-api";
import { LanguageSwitchComponent } from "./language-switch/language-switch.component";
import { StandaloneComponent } from "./standalone/standalone.component";
export interface User {
firstName: string
lastName?: string
}
@Component({
selector: "app-root",
standalone: true,
imports: [
// Components
LanguageSwitchComponent,
StandaloneComponent,
// Vendors
TranslateDirective,
TranslatePipe,
],
templateUrl: "./app.component.html",
})
export class AppComponent implements OnInit {
private _translate = inject(TranslateService);
title = _("test-app");
constructor() {
this._translate.addLangs(["de", "en"]);
this._translate.setDefaultLang("en");
this._translate.use("en");
}
ngOnInit() {
// Service Get method with a set of string[]
this._translate
.get(["demo.simple.text-as-attribute", "demo.simple.text-as-content"])
.pipe(
map((arr: TranslationObject) => {
return Object.values(arr).join(", ");
}),
)
.subscribe(console.info);
// Culprit
const user: User = {
firstName: 'Jone'
}
const title = this._translate.instant('demo.title', user)
console.log(title)
}
}
Proposed solution
- Either user won't be able to add Typed object inside the method anymore.
- Or they will need to add
[key: string]: unknown;in their interface declaration - Or we change
export type InterpolationParameters = unknown;
Note
This issue will never be fixed by typescript : / https://github.com/microsoft/TypeScript/issues/15300
I switched the type to
export type InterpolationParameters = Record<string, any>;
this ensures that we can use the string as index while also allowing objects.
@CodeAndWeb The version is production ready on my side
We’ve decided to move straight to v17, with a full rewrite of the extended and isolated logic. There shouldn’t be any changes to how you use the library, but this update fixes a ton of issues.
If you'd like to give it a try, the RC is available here: 👉 https://www.npmjs.com/package/@ngx-translate/core/v/17.0.0-rc.0
Your feedback is very welcome!
This version is already quite stable — no major changes expected. Happy coding!