core icon indicating copy to clipboard operation
core copied to clipboard

Next release

Open UrzaUrza opened this issue 8 months ago • 3 comments

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)

UrzaUrza avatar Mar 20 '25 13:03 UrzaUrza

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

wamasimba avatar Mar 29 '25 12:03 wamasimba

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 : )

rbalet avatar Jun 02 '25 09:06 rbalet

@CodeAndWeb I found the following, but I'm wondering if this is due to it being the release candidate.

Image

I imported it locally and it seems to be working just fine. So you have my green light

rbalet avatar Jun 02 '25 09:06 rbalet

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 avatar Jun 16 '25 12:06 UrzaUrza

@UrzaUrza

  1. same happened to me
  2. For this one I'm not sure of the reason behind the depreciation, and IMO the store shouldn't be accessed directly
  3. 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 ?

rbalet avatar Jun 16 '25 23:06 rbalet

@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

  1. Either user won't be able to add Typed object inside the method anymore.
  2. Or they will need to add [key: string]: unknown; in their interface declaration
  3. Or we change export type InterpolationParameters = unknown;

Note

This issue will never be fixed by typescript : / https://github.com/microsoft/TypeScript/issues/15300

rbalet avatar Jul 08 '25 17:07 rbalet

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 avatar Jul 09 '25 15:07 CodeAndWeb

@CodeAndWeb The version is production ready on my side

rbalet avatar Jul 09 '25 16:07 rbalet

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!

rbalet avatar Jul 22 '25 06:07 rbalet