plume-org / rocket_i18n Goto Github PK
View Code? Open in Web Editor NEWA crate to help you internationalize your Rocket applications.
License: GNU General Public License v3.0
A crate to help you internationalize your Rocket applications.
License: GNU General Public License v3.0
To avoid the need to add gettext as a dependency in Cargo.toml
every time.
For instance en-US
or pt-BR
Currently client's local is determined by the first local before a comma, but local may contain not only language but also country and some sort of priority tag. Those should get stripped before calling set_var. For exemple when connecting to a Plume instance, as my exact local is fr-FR,en-US;q=0.7,en;q=0.3
, set_var is called on fr-FR
, but translation is only available for fr
, so I get default language instead of french.
How to reproduce :
$ curl https://baptiste.gelez.xyz/ -H "Accept-Language: fr" | grep h1
$ curl https://baptiste.gelez.xyz/ -H "Accept-Language: fr-FR" | grep h1
Notice one is in french, the other in english
https://docs.rs/accept-language/2.0.0/accept_language/
It probably handles all edge cases better than we do, and will help us to de-duplicate the code between rocket and actix implementations.
Hey folks,
as always, thanks for your work on this lib!
Rocket recently released a 0.5 release candidate, with Rust stable and async support. I'm wondering, are there plans to update this library to the new version?
please bump the version to 0.4.0 :)
There is a race condition due to use of a global variable to store language, if two request are made close enought, one will inherit the language of the other
How to reproduce :
$ for i in `seq 1 50`; do curl https://baptiste.gelez.xyz/ -H "Accept-Language: en" 2>/dev/null | grep 'h1'& done
$ for i in `seq 1 50`; do curl https://baptiste.gelez.xyz/ -H "Accept-Language: fr" 2>/dev/null | grep 'h1'& done
Running one command then another give consistant results, but running both at the same time on different terminals sometime give inconsistant language result.
I don't know how this can be easily fixed as gettext-rs make heavy use of global state to store local
The gettext processes we spawn here https://github.com/BaptisteGelez/rocket_i18n/blob/master/src/lib.rs#L196, here https://github.com/BaptisteGelez/rocket_i18n/blob/master/src/lib.rs#L205 and here https://github.com/BaptisteGelez/rocket_i18n/blob/master/src/lib.rs#L226 are not correctly killed when they end, they end up as zombies.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.