Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow for default messages to be localized #40

Open
nicolasbinet opened this issue Oct 4, 2020 · 16 comments
Open

Allow for default messages to be localized #40

nicolasbinet opened this issue Oct 4, 2020 · 16 comments

Comments

@nicolasbinet
Copy link

This would be nice to be able to localize, or change, default errors message.
Maybe though the defaultConfig parameter ?

Thanks.

sha256 added a commit that referenced this issue Oct 6, 2020
@kevinmu17
Copy link

Would be nice to have a default config option like errorText :)

@kevinmu17
Copy link

Oh, I see this commit c820761 but somehow can't seem to get it to work. It gives me an error:
.setLocale is not a function

@kevinmu17
Copy link

@sha256 can you maybe point us in the right direction here??

@sha256
Copy link
Owner

sha256 commented Mar 18, 2021

@kevinmu17, sorry I have been very busy lately. Please see the last 2 test cases from here:

https://github.com/sha256/Pristine/blob/feature/i18n/test/locale.test.js

@kevinmu17
Copy link

Thanks for the reply! I'm trying to test addMessages now, but same result:
Pristine.addMessages is not a function.

Both examples below are not working :(

import Pristine from 'pristinejs';

Pristine.addMessages('en', {
    'email': "Email not valid"
})
let pristine = new Pristine(form, defaultConfig, true);
pristine.addMessages('en', {
    'email': "Email not valid"
})

@sha256
Copy link
Owner

sha256 commented Mar 18, 2021

@kevinmu17, could you please double check if you're using the right lib files?
from here: https://github.com/sha256/Pristine/tree/feature/i18n/dist

@kevinmu17
Copy link

Yes, checked my output and it says: "./node_modules/pristinejs/dist/pristine.js"

@kevinmu17
Copy link

I installed the plugin with NPM, it seems the code isn't on there. I crosschecked it with the files on github and addMessages is no where to be found. Does pristine needs an update on NPM?

@manchumahara
Copy link

As I found the npm version and the last released version in github are not same file but npm package.json file saying same version. That is why 'addMessages' function is not available in npm version to be clear as I just checked. BTW, it's a nice library.

@or3lie
Copy link

or3lie commented Jan 17, 2023

Hello, I installed Pristine with yarn and I can't use setLocale (I need to set french verion for error messages)
Is there an update planned for this point or how can I set my messages to french without that ?
Thanks

@kevinmu17
Copy link

Hello, I installed Pristine with yarn and I can't use setLocale (I need to set french verion for error messages) Is there an update planned for this point or how can I set my messages to french without that ? Thanks

This repo is abandoned. a fix you can do is get the github repo link:

pacakage.json

 "dependencies": {
    "pristinejs": "git+https://github.com/sha256/Pristine.git",
  },

@or3lie
Copy link

or3lie commented Jan 17, 2023

ok, thank you for the help

@thomas-franz
Copy link

Hey @sha256! First of all, thank you for your effort in creating and maintaining this validator.
Could you please create a new version and publish it to NPM?

@sha256
Copy link
Owner

sha256 commented Feb 9, 2023

Hey @thomas-franz, thanks for the nudge and sorry for not maintaining it properly. I have just bumped the version and published to NPM.

@thomas-franz
Copy link

@sha256 thank you so much! Is there any way to buy you a coffee? :)

@yevheniiorhanistyi
Copy link

Solved the problem in the local copy of node_modules in this way:

Pristine.prototype.setLocale = function (locale) {
    currentLocale = locale;
};
Pristine.prototype.addMessages = function (locale, messages) {
    var langObj = lang.hasOwnProperty(locale) ? lang[locale] : lang[locale] = {};

    Object.keys(messages).forEach(function (key, index) {
      langObj[key] = messages[key];
    });
};

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants