You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have been trying to access our translations in our server responses: outside of the svelte store lifecycle. I have figured out that I can do something similar to this:
import{_,addMessages}from'svelte-i18n';importenfrom'../../../../i18n/en.json';importukrfrom'../../../../i18n/ukr.json';addMessages('en',en);addMessages('ukr',ukr);lettranslate=(message: string,options: object)=>'translator not set up yet';_.subscribe((f)=>{translate=f;});consttranslation=translate('app.page_not_found',{locale: 'ukr'});console.log(translation);
This gets the correct translations out of the provided files. I keep thinking there must be an easier way to do this, But I can't find anything in the documentation. It seems to me like the svelte-i18n api should expose a simple function to get a translation, if it has already been registered, outside of the store and front-end lifecycle. In our case we can get the locale from the database, the user's preferences, or read the cookies in the api response.
Am I missing something?
The text was updated successfully, but these errors were encountered:
I have been trying to access our translations in our server responses: outside of the svelte store lifecycle. I have figured out that I can do something similar to this:
This gets the correct translations out of the provided files. I keep thinking there must be an easier way to do this, But I can't find anything in the documentation. It seems to me like the
svelte-i18n
api should expose a simple function to get a translation, if it has already been registered, outside of the store and front-end lifecycle. In our case we can get the locale from the database, the user's preferences, or read the cookies in the api response.Am I missing something?
The text was updated successfully, but these errors were encountered: