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

Locale for uploadbox sets wrong property

This code:
            @(Html.EJ().Uploadbox("albumUpload").CssClass("albumUpload")
                  .UploadBoxDialogAction(e => e.CloseOnComplete(false))
                  .ExtensionsAllow(".jpg, .jpeg, .png")
                  .ExtensionsDeny(".pdf, .docx")
                  .MultipleFilesSelection(true)
                  .UploadName("albumUpload")
                  .AllowDragAndDrop(true)
                  .ShowFileDetails(true)
                  .Locale("en-US")
                  )
Generates this HTML:

            <div id="albumUpload"
                 data-role="ejuploadbox"
                 data-ej-locale="en"
                 data-ej-allowdraganddrop="true"
                 data-ej-extensionsallow=".jpg, .jpeg, .png"
                 data-ej-extensionsdeny=".pdf, .docx"
                 data-ej-uploadname="albumUpload"
                 data-ej-cssclass="albumUpload"></div>

Instead of the HTML with the correct locale:

            <div id="albumUpload"
                 data-role="ejuploadbox"
                 data-ej-locale="en-US"
                 data-ej-allowdraganddrop="true"
                 data-ej-extensionsallow=".jpg, .jpeg, .png"
                 data-ej-extensionsdeny=".pdf, .docx"
                 data-ej-uploadname="albumUpload"
                 data-ej-cssclass="albumUpload"></div>

9 Replies

PO Prince Oliver Syncfusion Team May 11, 2017 12:25 PM UTC

Hi Wouter,   
  
Thank you for contacting Syncfusion support.   
  
The default locale is en-US, hence setting it in the locale will not reflect in html. In case, if you have set ar-AE (Arabic) or any other language in locale, it will be set to the data-ej-locale attribute. This is the default behavior in our controls.   
  
We have prepared a sample demonstrating locale (en-US) in upload box. Kindly refer to the following link for the sample: https://www.syncfusion.com/downloads/support/forum/130386/ze/uploadSample400272443 
  
Regards,   
Prince      



WO Wouter May 11, 2017 01:56 PM UTC

Thanks for your answer, but this is not the solution. My application runs in the "en" culture (invariant culture). Setting the locale to Locale("en-US") results in this html attribute: data-ej-locale="en". As you point out, when the running culture matches the given locale the attribute is omitted. In this case the attribute is included with an invalid value. Omitting would be far better in this case.

I had a hard time running your example, but I updated it to make it work and display the aforementioned issue. You can download it here: https://www.dropbox.com/sh/y5pf769c8j4l2p9/AACeHMqhTHT5b0aafeYqtOcUa/SF.Sample.Upload.zip?dl=0






PO Prince Oliver Syncfusion Team May 12, 2017 07:28 AM UTC

Hi Wouter,      
  
Thank you for your update.   
  
We checked the shared modified sample, but we were unable to reproduce the issue, it is working as expected. Refer to the following screenshot.   

 

Please provide us additional details to reproduce the issue. Provide us the Syncfusion version of your using, browser version and Operating system. It may help us replicate the issue and provide solution.   
  
Regards,   
Prince    



WO Wouter May 12, 2017 07:54 AM UTC

I got this: (included code that sets the cultureinfo)




PO Prince Oliver Syncfusion Team May 15, 2017 10:22 AM UTC

Hi Wouter,   
  
Thank you for your update.   
  
We have included the cultureInfo in application begin request method as per the shared screenshot and set the culture as “en”, we are unable to reproduce the issue in locale. Kindly refer to the following link for the Sample: https://www.syncfusion.com/downloads/support/forum/130386/ze/uploadSample400272443 
  
You can try setting the culture as “en-US” instead of “en”, to check if it resolves the issue. Kindly refer to the following code snippet.   

protected void Application_BeginRequest(Object sender, EventArgs e) 
        { 
            CultureInfo ci = new CultureInfo("en-US") {  DateTimeFormat = { ShortDatePattern = "dd-MM-yyyy" } }; 
            Thread.CurrentThread.CurrentUICulture = ci; 
            Thread.CurrentThread.CurrentCulture = ci; 
        } 

Regards, 
Prince 



WO Wouter May 16, 2017 12:37 PM UTC

Hi Prince Oliver,

Setting the culture to "en-US" does solve the problem, but that is not an option for us. Our real solution is a bit more complex. The problem is that the component cant cope with a neutral culture.  Setting the thread to culture "en" shouldnt result in the component rendering " data-ej-locale="en" " since this cannot be handled. If the component would fall back to using "en-US" it's still usable. This is just a case of the component rendering itself into an unusable state.

Regards,




PO Prince Oliver Syncfusion Team May 18, 2017 05:58 AM UTC

Hi Wouter,   
  
Thank you for your update.   
  
When the locale is set as “en”, the uploadbox control will not be rendered as the localization for “en” is not defined. We have defined and set “en-US” as default localization which will be set only if locale property is undefined. So, in your case we need to define localization for “en” or we can copy it from “en-US”. Kindly refer to the following code snippet.   

<script> 
        ej.Uploadbox.Locale["en"] = ej.Uploadbox.Locale["en-US"] 
</script> 
  

Regards, 
Prince 



WO Wouter May 18, 2017 10:24 AM UTC

> "When the locale is set as “en”, the uploadbox control will not be rendered as the localization for “en” is not defined. "

That's what I was saying all along.

I already had a workaround. I'll leave this to syncfusion, but I think the control should render only one of the available localizations in any case. The point is to use MVC controls, without extra workarounds in JS, otherwise a JS would be more fitting.


PO Prince Oliver Syncfusion Team May 19, 2017 05:42 AM UTC

Hi Wouter,      
     
Thank you for your update.     
  
As mentioned in the previous update, default localization will be used only when the localization is not set manually. You have set localization in cultureinfo as “en”, so it is set to the control after serializing. Our controls are render based on JavaScript, hence we need to use the JS workaround provided in the previous update.   
  
Regards,   
Prince   


Loader.
Up arrow icon