We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Localization / Globalization

Hi,
I try to migrate a from a competitors controls suite to syncfusion.
At the moment I have a lot of problems with localization / globalization.
My scripts -
<scriptsrc="~/lib/jsrender/jsrender.min.js">script>
<scriptsrc="~/lib/syncfusion-javascript/Scripts/ej/web/ej.web.all.min.js">script>
<scriptsrc="~/lib/syncfusion-javascript/Scripts/ej/common/ej.globalize.min.js">script>
<scriptsrc="~/syncfusion/i18n/ej.culture.de-DE.min.js">script>	
<scriptsrc="~/syncfusion/l10n/ej.localetexts.de-DE.min.js">script>
<script>
	if(typeof(ej.globalize)!='undefined'){
		console.log('@System.Threading.Thread.CurrentThread.CurrentCulture.Name');
 
		ej.globalize.preferredCulture("de-DE");
 
		console.log(ej.globalize.format(53422,'C'));//FormattingPrice
			console.log(ej.globalize.format(newDate(2016,07,15),'D'));//Formattingdate
			console.log(ej.globalize.format(123123.576,'n2'));//Formattingnumber
		}
script>
The output is ENGLISH - no german text / date / time / currency.
The "Dynamic Solution" with
<scriptsrc="~/syncfusion/i18n/ej.culture.@(System.Threading.Thread.CurrentThread.CurrentCulture.Name).min.js">script>	
doesn't work too. Or lets say it works "somehow".
Since you don't offer all scripts via bower (I can't use npm in my solution) I searched the product installation in my programms directory.
There are also only the "basic files". So I downloaded the source from github and installed it manually.
Now my locale de-AT works! - At least for the controls.
Or to be more precise -for the globalization of the controls. In a datetimepicker I can see the correct date format - the corect month name and so forth.
BUT - the button keeps at "today" - instead of "heute".
With my current product I choose the correct locale file - the rest jus works. By the way there is also a simple way to install all locales wich include de-AT, de-CH and so on.
Anyhow - for syncfusion I have to extra add a localetexts script from l10N. And I have to set the locale at every single control.
And here the next problem comes in -- l10N has a very limited number of locales files - so for an example no de-AT is there.
I checked the number l10n 56 files - i18n - around 750.
In i18n are "fallback files" (like .....de.js - which I could choose for the case de-AT is not found) - nothing like this in l10n.
Anyhow my problems are:
1.) Scripts ej.globalize.... are not working.
2.) Missing l10n files

For 1.) I hope that I'm just missing something from the documentation.
For 2.) - I had a similarproblem with a competitor control suite . all we had to do was "choose an almost matching file".
In simple words - I checked that de-AT was not present - and choose de-DE instead - cs-CZ not found - chose en-US instead.
Simple - but working since it was enough to include one single file - the rest was done by the framework.
No need to decorate every single control or to include extra files.
My Questions
a.)-what's wrong with the scripts?
b.) how to solve the "missing locales files" and still be dynamic

7 Replies

SA Shameer Ali Baig Sulaiman Ali Baig Syncfusion Team October 12, 2017 12:01 PM UTC

Hi Manfred, 
 
Thanks for contacting Syncfusion Support. 
 
We have checked with your query. We are unable to reproduce the issue in DateTimePicker. We have provided the locale text files for 28 cultures (specified in the GitHub location), since complexity in providing locale text for all 376 cultures.     
   
If you need German (Austria) (‘de-AT’), please create a locale text script file for ‘de-AT’ with necessary components and include this file in your application to render the desired components with ‘de-AT’ text. You can make use of English (en-US) culture as reference for creating locale texts of other culture. In this manner, please include the required control’s locale text and make use of this file in your application.    
  
·       I18n folder has all the culture script files which has support with Syncfusion components  
  
·       l10n folder has all the locale texts script files which has support with Syncfusion components. 
  
 
To globalize and localize the Syncfusion components into a particular culture, it is necessary to refer the below specified scripts in your application
 
  • ej.globalize.min.js is mandatory for processing specific source-side actions globally, in this we are having methods to set the culture.
(ej.globalize.min.js library avails as built-in within ej.web.all.min.js file, therefore it is not necessary to externally refer it in your application) 
  
  • Culture-specific script files (eg: ej.culture.de-DE.min.js ), which contains specific culture that you need to adapt any of our Syncfusion control.
  
  • To localize the DateTimePicker control into de-DE culture is to refer the ej.localetexts.de-DE.min.js file below the ej.culture.de-DE.min.js.
 
·       Seven culture-specific script files are available in the below specified location. For all other culture files, please download from the GitHub  location. 
  
 
·       In your Asp.NET Core application, refer the script files in _Layout.cshtml file below the ej.web.all.min.js to as depicted below 
 
<script src="@Url.Content("~/js/jsrender.min.js")"></script> 
<script src="@Url.Content("~/js/ej/ej.web.all.min.js")"></script> 
<script src="~/js/ej/i18n/ej.culture.de-DE.js"></script> 
<script src="~/js/ej/l10n/ej.localetexts.de-DE.js"></script> 
  
·       Else, refer the ej.culture.de-DE.min.js and ej.localtexts.de-DE.min.js above any .cshtmls were you render the Syncfusion controls. 
For your convenience, we have also prepared a sample with globalization support for DateTimePicker which can be downloaded from the below given link. 
  
Sample: 
  
  
 
Regards, 
  
Shameer Ali Baig S. 



MA ManniAT October 12, 2017 12:42 PM UTC

Hi Shameer,

maybe I wasn't precise enough with my questions.

First of all - thank you for the answer and the sample.

Unfortunately the sample shows something I allready have.

It's more or less a prove of the problems I got...
l10n must exist - else the system fails.
There is no "hidden source" for those files - they simply do not exist.
I have to write locale="...." on every single control.

Missing (just an example) de-AT l10n files...
And your idea "write the file at your own..." is not really possible.
YES I could write the de-AT (using de-DE as base since they are very close).
The same for de-CH - but what about the big rest which is missing??????

Anyhow - you may have overseen my question about the scripts:

<script>
	if(typeof(ej.globalize)!='undefined'){
		console.log('@System.Threading.Thread.CurrentThread.CurrentCulture.Name');
 
		ej.globalize.preferredCulture("de-DE");
 
		console.log(ej.globalize.format(53422,'C'));//FormattingPrice
			console.log(ej.globalize.format(newDate(2016,07,15),'D'));//Formattingdate
			console.log(ej.globalize.format(123123.576,'n2'));//Formattingnumber
		}
script>

Could you tell me  how to make this work???

If I copy this to the project you provided - it still shows "english formats" - or in other words - it doesn't work.

And one more question about it:

ej.globalize.preferredCulture("de-DE");

If I write this - does it also work for controls?
So that I don't have to write locale="...." on every singe control?

Thank you

Manfred



MK Mohan Kumar Ramasamy Syncfusion Team October 13, 2017 01:10 PM UTC

Hi Manfred,  
 
Sorry for the inconvenience caused. 
 
We have considered your request, we will provide the “de-AT” culture localetexts file in any of our upcoming releases.   
 
Regards, 
Mohankumar R 



MA ManniAT October 13, 2017 02:44 PM UTC

Hi,

although it's nice that you are willing to provide a de-AT this doesn't fix the problem as long as localization is not completely done I can't rely on it since I don't know where my visitors come from.

WHAT ABOUT THE SCRIPTS?

Is there a way to make them working?

Regards

Manfreds



MK Mohan Kumar Ramasamy Syncfusion Team October 16, 2017 01:10 PM UTC

Hi Manfred,  
 
Sorry for the inconvenience caused. 
 
Query1: Localization “de-AT” culture 
We are unable to provide the localization(“de-AT”) for all our components. So, can you please share the sample list which you are using currently in your project. So, we can check the possibilities and update the details. 
 
Query2: To set culture globally 
We have checked your query and we would like to suggest you to use ej.setCulture method, this method globalize all the Syncfusion controls in your application. Please, refer the scripts in your application’s _Layout.cshtml as depicted below.  
  
[scripts reference]  
     
 <script src="@Url.Content("~/js/jsrender.min.js")"></script>  
        <script src="@Url.Content("~/js/ej/ej.web.all.min.js")"></script>  
        <script src="~/js/ej/i18n/ej.culture.de-DE.js"></script>  
        <script src="~/js/ej/l10n/ej.localetexts.de-DE.js"></script>  
        <script>  
        ej.setCulture("de-DE")  
        </script>          
   
For, your convenience we have prepared a sample based on your requirement. Please, download the sample from the below location.  
   
   
Please let us know if you need any further assistance.  
 
Regards,  
Mohankumar R  



HO horacioj May 31, 2018 04:00 AM UTC

Hello,

Perhaps I'm missing something.
Are these (JS 2 version 16.1.0.37,  May 2018) the only available culture files? 
  • ej.culture.fr-FR.js
  • ej.culture.vi-VN.js
  • ej.culture.zh-CN.js
  • ej.culture.ar-AE.js
  • ej.culture.de-DE.js
  • ej.culture.en-US.js
  • ej.culture.es-ES.js

How should I proceed if the user's culture is set to en-GB or es-AR, pt-BR, .etc. ? 
It seems to be tons of cultures are missing?

The same questions goes regarding the ej.localetexts.xx-XX.js files.


Besides, after lots of hours, I'm still unable to make it work.
I'm using plain javascript.
I have references set to ej2.min.js, ej.culture.{UserLanguage}.js, and ej.localetexts.{UserLanguage}.js

How (in plain JavaScript) can I set the localization stuff globally?
All of this throw errors:
  • ej.setCulture("es-ES");
  • ej.globalize.setCulture("es-ES");
  • ej.base.setCulture('es-ES');

Trying to set it explicitly in the grid fails too:
var grid = new ej.grids.Grid({
            locale: 'es-ES',
            ....
            ....

Even the reference alone to ej.culture.es-ES.js doesn't work:
ej.culture.es-ES.js?cdv=42:1 Uncaught TypeError: ej.addCulture is not a function
    at ej.culture.es-ES.js

What am I missing?



Thanks


VA Venkatesh Ayothi Raman Syncfusion Team June 1, 2018 01:35 PM UTC

Hi Horacio, 

Thanks for using Syncfusion products. 

Due to package bundling weightage we have bundle the minimal culture files as following, 
  • ej.culture.fr-FR.js
  • ej.culture.vi-VN.js
  • ej.culture.zh-CN.js
  • ej.culture.ar-AE.js
  • ej.culture.de-DE.js
  • ej.culture.en-US.js
  • ej.culture.es-ES.js
In Essential JS2 whole culture CLDR files available in npm package. So, you can install it through the below command to our package. 
npm install cldr-data 
 
So, we can load the corresponding CLDR data and referred the corresponding culture name in Grid locale property like as follows, 
Code example
Grid.Inject(Toolbar, ExcelExport, Page); 
 
declare var require: any; 
 
loadCldr( 
    require('cldr-data/main/ar/numbers.json'), 
    require('cldr-data/main/ar/ca-gregorian.json'), 
    require('cldr-data/main/ar/numbers.json'), 
    require('cldr-data/supplemental/numberingSystems.json'), 
    require('cldr-data/main/ar/timeZoneNames.json') 
); 
 
 
let grid: Grid = new Grid({ 
    dataSource: data, 
    locale:'ar'
    allowExcelExport: true, 
    toolbar: ['ExcelExport'], 
    columns: [ 
. .  
    ], 
    height: 315 
}); 
grid.appendTo('#Grid'); 


We have also prepared a sample for your convenience which can be download from following link, 

Note: As you have said ‘ have references set to ej2.min.js, ej.culture.{UserLanguage}.js, and ej.localetexts.{UserLanguage}.js’, here highlighted files are belongs to Essential JS 1 not Essential JS 2. Here, the globalization library provides support for formatting and parsing date and number objects using the official Unicode CLDR JSON data. So, we need to refer the CLDR json files instead of Essential JS1 js files.  

Regards, 
Venkatesh Ayothiraman. 


Loader.
Live Chat Icon For mobile
Up arrow icon