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

Distinguish perfect match from best fit #9

Closed
peter-scholtens opened this issue Jul 31, 2023 · 1 comment
Closed

Distinguish perfect match from best fit #9

peter-scholtens opened this issue Jul 31, 2023 · 1 comment

Comments

@peter-scholtens
Copy link
Contributor

For a webserver where new languages are added later on during the deployment phase, I would like to detect if the user languages are a perfect/default match (q=1) or a best fit (q<1). The idea is that only with a perfect match the user information in the database will be updated/initialized.

With for example nl,en-US;q=0.7,en;q=0.3 the user would get the en-US translation first, but when the site owner finishes the nl translation later on the user would be served with that (unless deliberately chosen otherwise). To offer this, I need to detect if the first item in the vector is a perfect match (or default) language of the user or just a best fit. The function signature would than include a boolean value which is true if the first item in the array is the perfect match / default value, and otherwise false. Like below:

pub fn intersection_verify_default(raw_languages: &str, supported_languages: &[&str]) -> (bool,Vec<String>) {...}

Would you accept such a patch?

@peter-scholtens
Copy link
Contributor Author

A patch is written, see this pull request #12, however with a boolean value for each listed String.

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