LoginSignup
1
1

More than 5 years have passed since last update.

jquery.MultiFile のエラーメッセージを日本語化

Last updated at Posted at 2019-02-22

自分用。せっかく書いたはいいが、没になったので。
公式サイトも消えて、後継サイト?のドキュメントに書いている内容は
ソースコードの記述と食い違っているなど色々苦労しました。

/**
 * jquery.MultiFile
 *
 * @see https://github.com/fyneworks/multifile
 * @see http://lampspw.wallonie.be/dgo4/tinymvc/myfiles/plugins/multifile-2.2.1/docs.html
 */
function initMultiFile()
{
    var target, acceptExtention, maxFileUploads, maxUploadFileSize, postMaxSize, previewCssStyle;

    target = '.multi-files';
    acceptExtention = 'jpg|png|gif';
    maxFileUploads = 20;
    maxUploadFileSize = 256; // KB
    postMaxSize = maxUploadFileSize * maxFileUploads; // KB
    previewCssStyle = 'max-height:100px; max-width:100px;';

    $(target).MultiFile({
      accept: acceptExtention,
      max: maxFileUploads,
      maxfile: maxUploadFileSize,
      maxsize: postMaxSize,
      preview: true,
      previewCss: previewCssStyle,
      STRING: {
          remove: 'x',
          denied: '許可されていない拡張子です:$ext',
          file: '$file', // span.MultiFile-title text
          selected: '$file', // span.MultiFile-label title attribute
          duplicate: 'アップロード済みのファイルです:$file',
          toomuch: '同時アップロード可能ファイルサイズの上限に到達しました\n (最大サイズ:$size)',
          toomany: '同時アップロード可能ファイル数の上限に到達しました\n (最大数:$max)',
          toobig: 'ファイルサイズが大きすぎます:$file\n (最大サイズ:$size)'
      }
    });
}
1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1