parsley.js没有显示法语错误消息

时间:2014-11-18 16:30:21

标签: javascript parsley.js

我已经安装了Parsley.js并且工作正常(很容易)但是我无法用法语显示错误消息。我已经尝试了both methods detailed in the documentation但是错误信息仍然以英文显示。

我已经检查了控制台并且没有错误,我也可以直接在浏览器中加载语言文件,因此它就在那里。

我目前的代码是:

  <script src="/js/parsley/i18n/en.js"></script>
  <script src="/js/parsley/i18n/fr.js"></script>
  <script src="/js/parsley/parsley.min.js"></script>
  <script type="text/javascript">
    window.ParsleyValidator.setLocale('fr');
  </script>

请告知。

3 个答案:

答案 0 :(得分:3)

我也无法按照parsley.js页面上的说明进行操作。

这对我有用,因为截至2015年11月18日,在欧芹页面上的文档仍然无效。

1-首先是欧芹js然后是本地化文件(来自https://github.com/guillaumepotier/Parsley.js/tree/master/src/i18n):

 package finalversion2;

import java.util.Arrays;
import java.util.Random;

public class AWorld {

    int x[] = new int[10], y[] = new int[10];
    int row = 25;
    int column = 25;
    char[][] map;

    public static int RandFood(int min, int max) {
        Random rand = new Random(); // Initializes the random function. 

        int RandNum = rand.nextInt((max - min) + 1) + min; //generates a random number within the max and min ranges 
        return RandNum; //returns the random number 
    }


    //Constructor
    //Sets up map array for the AWorld object
    //uses a bug that is passed to it
    public AWorld(ABug bug) {

        ABug bug1 = bug;

        map = new char[row][column];



        for (int i = 0; i < row; i++) {

            for (int x1 = 0; x1 < column; x1++) {

                map[i][x1] = ' ';

            }

        }

        for (int i = 0; i < column; i++) {
            Random rand = new Random();
            int x = rand.nextInt(row);
            int y = rand.nextInt(column);
            map[x][y] = (char) RandFood(48, 57);
            map[bug1.getHPossistion()][bug1.getVPossistion()] = bug1.getSymbol(); // gets the bugs x and y possistion in the array (user defined) and puts it into the symbol variable 
        }



    }


    public void PrintWorld() {
        for (int i = 0; i < row; i++) //these next two for loops print the array to the screen 
        {
            System.out.print("|");
            for (int x1 = 0; x1 < column; x1++) {
                System.out.print(map[i][x1]);
            }
            System.out.println("|");
        }

    }
}

ABug:

    package finalversion2;

public class ABug 

{


    public static void main(){

    }

        private String species = new String(); //instance variables (defines data of object)
        private String name = new String();
        private String description = new String();
        private char symbol;
        private int hPossistion, vPossistion, energy, iD;

        public ABug(){

        }

        public ABug (String s, String n, String d, int h, int v, int e, int i){
            this.species = s;
            this.name = n;
            this.description = d;
            this.symbol = s.charAt(0);
            this.hPossistion = h;
            this.vPossistion = v;
            this.energy = e;
            this.iD = i;
        }




        //setters
        public void setSpecies(String s){
            this.species = s;
        }

        public void setName(String n){
            this.name = n;
        }

        public void setSymbol(char symbol){
            this.symbol = symbol;
        }

        public void setHPossistion(int x){
            this.hPossistion = x;
        }

        public void setVPossistion(int y){
            this.vPossistion = y;
        }

        public void setEnergy(int energy){
            this.energy = energy;
        }

        public void setID(int i){
            this.iD = i;
        }

        public void setDescription(String d){
            this.description = d;
        }

        //getters
        public String getSpecies(){
            return this.species;
        }

        public String getName(){
            return this.name;
        }

        public char getSymbol(){
            return this.symbol;
        }

        public int getHPossistion(){
            return this.hPossistion;
        }

        public int getVPossistion(){
            return this.vPossistion;
        }

        public int  getEnergy(){
            return this.energy;
        }

        public int getID(){
            return this.iD;
        }

        public String getDescription(){
            return this.description;
        }

        public String toString(){
            String BugData;
            BugData = name + " " + symbol + "\n" + species + "\n" + description;
            return BugData;
        }

}

enum Direction: 

    package finalversion2;


public enum Direction {
    NORTH,  EAST,   SOUTH,  WEST;
}

2-编辑本地化文件:注释“导入”,然后添加“窗口”。在每个2 js指令之前。例如:

<script src="parsley.min.js"></script>
<script src="i18n/es.js"></script>

答案 1 :(得分:0)

Parsley依赖于jQuery(&gt; = 1.8),在包含Parsley之前需要包含它。

答案 2 :(得分:0)

如果有人看到此内容并寻找答案:

我可以通过在代码周围添加“ $(document).ready(function(){}”)来解决此问题。

for(FromBean fromBean: fromBeanList) {
    if(fromBean != null) {
        ToBean toBean = new ToBean();
        org.springframework.beans.BeanUtils.copyProperties(fromBean, toBean);
        toBeanList.add(toBean);
    }
}