Coder Social home page Coder Social logo

plume-org / rocket_i18n Goto Github PK

View Code? Open in Web Editor NEW
15.0 15.0 6.0 57 KB

A crate to help you internationalize your Rocket applications.

License: GNU General Public License v3.0

Rust 100.00%
gettext i18n internationalization l10n localization rocket rust

rocket_i18n's People

Contributors

asonix avatar elegaanz avatar lthms avatar ogoffart avatar trinity-1686a avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

rocket_i18n's Issues

Correctly parse local from client

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

rocket 0.5 compatibility

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?

Request may be translated to the wrong language due to race condition

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.