Coder Social home page Coder Social logo

Add i18n about castro HOT 7 CLOSED

Raggaer avatar Raggaer commented on July 4, 2024
Add i18n

from castro.

Comments (7)

joseluis2g avatar joseluis2g commented on July 4, 2024

Nice 😍

from castro.

Raggaer avatar Raggaer commented on July 4, 2024

Added to main branch, will keep this open incase any issue appears

from castro.

joseluis2g avatar joseluis2g commented on July 4, 2024

I got a question.
How do I create a language switcher?

from castro.

Raggaer avatar Raggaer commented on July 4, 2024

I forgot to add the default language array, i18n.Language is a lua table with all languages the user accepts...

You can use a widget and using a session or an http cookie to save the language the user selects (on a widget or on the header using a ajax request to a page)

from castro.

joseluis2g avatar joseluis2g commented on July 4, 2024

Can you make an example? I think I do not understand it at all but I will do my tests for sure.

from castro.

Raggaer avatar Raggaer commented on July 4, 2024

On your templates you call something like

{{ i18n .session.lang "index" }} to display content

On the first request .session.lang will be empty, if its empty the default.i18n language file will be used.

To switch languages you can make a lua page that calls session.set("lang", "LANGUAGE") to update the laanguage the user wants to use

from castro.

joseluis2g avatar joseluis2g commented on July 4, 2024

Got it

from castro.

Related Issues (20)

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.