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

Interference character | (Straight line) In Lang.choice function #93

Open
MohammadZarifiyan opened this issue Oct 24, 2024 · 0 comments

Comments

@MohammadZarifiyan
Copy link

MohammadZarifiyan commented Oct 24, 2024

When I use choice() and use straight line symbol (|) in the parameters, it causes the sentence structure to be messed up. It seems that the library first places the parameters in the sentences and then selects the sentence based on the number parameter in choice(). While the correct way is to first select the correct sentence in terms of number, then replace the parameters.

Steps To Reproduce
home.php file:

return [
   'greeting' => '{0} Hello :name|[1,*] Hello :name, you have :count unread messages'
];

Usage:

import messages from '@/messages.json';
import Lang from 'lang.js';

const translator = new Lang({
    messages,
    locale: 'en',
    fallback: 'en'
});
translator.choice('home.greeting', 0, {name: 'Alex | Moi'});

Above code must result in Hello Alex | Moi, But it results to Hello Alex.

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

1 participant