Giter VIP home page Giter VIP logo

vaadin-i18n's Introduction

i18n

The goal of this project is to provide examples of how we can integrate i18n with Vaadin Flow quickly and easily, without any additional configuration.

In this demonstration, you can observe how we can switch between 4 languages: English, Spanish, Finnish, and French. The translations to Finnish and French have been made possible thanks to ChatGPT. This project illustrates the ease with which we can integrate multiple languages using Vaadin Flow, highlighting the functionality of dynamic language switching without the need for additional configurations.

Before proceeding, it is recommended to read the documentation and understand how i18n works in Vaadin. In this implementation, we are using the LocaleChangeObserver observer to receive events related to language changes. This approach allows us to dynamically manage language settings and adapt the user interface according to user preferences.

To use localization and translation strings, the application needs only to have the translation properties available on the classpath under the directory, vaadin-i18n with the filename prefix, translations. e.g.,

  • src/main/resources/vaadin-i18n/translations.properties
  • src/main/resources/vaadin-i18n/translations_es.properties
  • src/main/resources/vaadin-i18n/translations_fi.properties
  • src/main/resources/vaadin-i18n/translations_fr.properties

The file translations.properties is a default translation file that’ll be used for any Locale that doesn’t have a specific translations file.

Uere you can see an example of the application's behavior.

Demo.mp4

Running the application

The project is a standard Maven project. To run it from the command line, tab mvnw (Windows), or ./mvnw (Mac & Linux), then open http://localhost:37186 in your browser.

The 'defaultGoal' is configured in the pom file.

# Mac & Linux
./mvnw
# Windows
  mvnw

Deploying to Production

To create a production build, call

# Mac & Linux
./mvnw clean package -Pproduction

To create a production build, call

# Windows
mvnw clean package -Pproduction

This will build a JAR file with all the dependencies and front-end resources, ready to be deployed. The file can be found in the target folder after the build completes.

Once the JAR file is built, you can run it using

java -jar target/i18n.jar 

Deploying using Docker

To build the Dockerized version of the project, run

# Mac & Linux
./mvnw clean package -Pproduction
# Windows
mvnw clean package -Pproduction
docker build . -t vaadin-i18n-app:latest

Once the Docker image is correctly built, you can test it locally using

docker run -p 37186:37186 vaadin-i18n-app:latest

Project structure

  • MainLayout.java in src/main/java contains the navigation setup (i.e., the side/top bar and the main menu). This setup uses App Layout.
  • views package in src/main/java contains the server-side Java views of your application.
  • views folder in frontend/ contains the client-side JavaScript views of your application.
  • themes folder in frontend/ contains the custom CSS styles.

Useful links

vaadin-i18n's People

Contributors

fredpena avatar

Stargazers

Nick Bauters avatar Abdul Bashir Abdul Zahir avatar Juan Diego López avatar

Watchers

 avatar

vaadin-i18n's Issues

🧚🤖 Pixeebot Activity Dashboard

DashList

👋 This dashboard summarizes my activity on the repository, including available improvement opportunities.

Recommendations

Last analysis: Sep 19 | Next scheduled analysis: Sep 26

Open

✅ Nice work, you're all caught up!

Available

✅ Nothing yet, but I'm continuing to monitor your PRs.

Metrics

What would you like to see here? Let us know!

Resources

📚 Quick links
Pixee Docs | Codemodder by Pixee

🧰 Tools I work with
SonarCloud | SonarQube | CodeQL | Semgrep

🚀 Pixee CLI
The power of my codemods in your local development environment. Learn more

💬 Reach out
Feedback | Support


❤️ Follow, share, and engage with Pixee: GitHub | LinkedIn | Slack

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.