【问题标题】:jQuery File Upload Basic Plus Ui and i18njQuery File Upload Basic Plus Ui 和 i18n
【发布时间】:2015-12-03 10:22:14
【问题描述】:

我使用 jQuery File Upload Basic Plus Ui 来上传多个文件。我需要以多种语言(英语、法语和西班牙语)显示错误消息,但我不知道如何创建

messages: {
      maxNumberOfFiles: 'Maximum number of files exceeded',
      acceptFileTypes: 'File type not allowed'
      maxFileSize: 'File is too large',
      minFileSize: 'File is too smal
}

在多种语言中以及如何为

声明语言
file.error = settings.i18n('acceptFileTypes');

使用演示版,错误消息显示正常。

谢谢

【问题讨论】:

    标签: internationalization jquery-file-upload


    【解决方案1】:

    这里是如何实例化文件上传插件:

    $(document).ready(function() {
      $('#fileupload').fileupload({
         url: 'yoururl',
         acceptFileTypes: exttensionsRegex, 
         maxFileSize: yourmaxsize ,
         maxTotalFileSize: totalsize, 
         maxNumberOfFiles: numberoffiles , 
         messages: {
            maxNumberOfFiles: 'yourText',   
            acceptFileTypes: 'yourText' ,   
            maxFileSize:  'yourText',
            minFileSize:  'yourText'
         }
      });
    });
    

    如果此 javascript 是由您的服务器端代码生成的,那么您可以使用国际化 API 来获取正确的消息并将它们替换为 yourText

    至于:

    file.error = settings.i18n('acceptFileTypes');
    

    其实你什么都不用做,顺其自然就好。

    希望对你有帮助

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-05-28
      • 2014-08-26
      • 1970-01-01
      • 2014-06-06
      • 2015-03-06
      • 1970-01-01
      • 2014-02-18
      相关资源
      最近更新 更多