Force localizaition in SharePoint Framework (spfx) - javascript

I have a question regarding localization in SharePoint Framework. I have a simple webpart, which should change language not matter of the SharePoint settings. For example SP sites are full in English, but the user has to have a change to switch the language to Spanish or German. The question is how can I do it easily?
I have a webpart context which has localization property which are passed and normally, I suppose they are used to load the correct language, right?
So can I somehow programmatically change it? Or is there a another correct or better way?
Thanks in advance.

Related

Localization Angular 9 Medium size application

We have developed an application in Angular 9 (Only English words), Now we need to support Spanish language as well. all labels and headings are defined in HTML pages.
is there any way Can I convert all pages to Spanish with out creating / reading constant files (entering all headings and labels in constant .ts or JSON file)
I see ngx-translate but I see it's using constant files and reading it. (https://stackblitz.com/github/ngx-translate/example?file=src%2Fapp%2Fapp.module.ts)
If I need to follow the same, I need to create each page (Our application has 100 pages approx) data in JSON and read from it.
Please suggest if there is any easy solution to convert or suggest best way to implement it.
Thank you in advance.
the best way would still be creating a json file for each language and read from it. it helps you extends more language, for example some day you need french, japness, hindy, chinese...
by the way ngx-translate seems outdated, there is also transloco, which works great

Multi language on static website with i18next client side

I made a website with HTML, CSS and Javascript without using a CMS, so it's all kind of static. I've been asked to make this project into a multi language website (the current language and English). Now I am looking for a good way to implement all the translations.
I've seen a simple solution with i18next using client-side Javascript, but I'm wondering if this isn't harmful for SEO (the url doesn't change when selecting another language) and if there is a better solution for this.
https://github.com/dwkns/i18next-translation-tutorial
Hidden content may not be read by the search engines. It's better to have two versions of entire site in subfolders.
If you really want to do it with javascript, try to put both content visible in html (users with no javascript should see both) and then with javascript hide one of them after page loading. But i suggest the first approach, it's more realiable.
source about google do this: https://www.freshegg.co.uk/blog/technical-seo/google/how-does-google-treat-hidden-content
No issue with that. Google and other search engines run javascript as user browsers. Just add some links so google could discover the pages in other language (not only have autodetection)
The only drawback you have currently are routes are not translated but that could be solved, eg. https://github.com/i18next/i18next-express-middleware#add-localized-routes

jqGrid Language Detection

I am working on JqGrid and came across an issue related language. I need to support both English & French.
I added English and French locale file into the scripts folder and referred the files in the html file.But the jqGrid is not detecting the browser language automatically and display the last loaded language always.
Is there a better solution for this issue? Ideally, jqGrid should have capability to detect the language and load the locale file automatically. Couldnt find a solution anywhere.
Your help is highly appreciated. Thank you.

Changing site language with only javascript without server site code

My website only have 5 html page. I want to change language with javascript or jquery. How can i do that. I want to change language with one click but other page will still same language. What i must supposed to do?
Looks like Google has a free service for this
https://translate.google.com/manager/website/
You have very few options.
Have html version of your page in every language you have on your
website with corresponding links and maybe cookies to keep track of
your language.
Have all text in Javascript files and keep track of language in cookies and update text with JavaScript accordingly

How can i change the language of my Html5 hybrid application using java script and jQuery?

In my application i have a option of language selection.
When I select an option, the entire application language should be changed.
I have already tried using Google and Microsoft api but guess that is paid. Is there any free api using javascript that can help me regarding this problem.
This post might be what you are looking for. They are talking about:
A wordpress, change language plugin widget.
A jQuery handler to change language by directing to another url.
Have a nice day!
Two options:
#1
Have a look here. Click "Options" top right and select another langauges. Open a datebox plugin widget and it will be in the language you specified.
I like the way it's done using Crowdin, although you will end up with all your text in .js files. If you check out one of the languages sample files this will be a lot of meat to load if your site becomes more complex.
#2
Do this server side. I'm (using Coldfusion) loading a langauge object on first page load and cache this until the user selects a new language. My langauge object is about 60k with 2000 entries. You could also send this to the page from server via json and store it in the page, then you could reference it from Jquery/Javascript.
I will probably end up trying to switch from server side to using the first approach and will try to see if I can split up my language .js files according to JQM page and then load them together with require, which would mean only a few ks per page. If you don't mind having a bunch of langauge files for each language and page, this would probably be the best "Mobile" approach.

Categories