![]() ![]() You should now be able to build a multilingual Flask application on your own.Īs soon as you are ready to add even more languages to your app, think about streamlining your i18n process by signing up for Phrase, the leanest and most reliable translation management platform on the market. We are happy you were able to complete our Flask tutorial on internationalization. Here is the German version of our web page: Let's change the URL as follows: localhost:5000/dashboard/de_DE Modify it accordingly if you had specified a different port. Make sure that you are calling from the root directory. Once you are done with it, run the following command in the terminal to start your Flask application. With open(lang, 'r', encoding='utf8') as file: The goal of this article is to help you minimise doing eating the same thing over and over in your next Flask API project. ![]() Language_list = glob.glob("language/*.json") We often find ourselves rewriting the same boilerplate code like configuration, structure, and the build and deployment setup when writing a Flask web service. Return render_template('index.html', **languages, stats = stats, currencies = currencies, update_time = last_updated_time) In this case, I have the translation for German. The user can select a chart from a drop-down menu and the new chart will be displayed. Each JSON file represents a language that contains all the translations for your application. Flask is a Python web app framework for making server-based apps. Inside the folder, create a new JSON file called de_DE.json. In your project directory, create a new folder called language. pip install flask Language Files German (de_DE) Run the following command in the terminal. It is highly recommended to create a virtual environment before you continue with the installation. You can clone it via Git or download it directly as a zip file. Ready to start? The Setupįirst and foremost, check out our GitHub repository for the complete code used in this tutorial. All of them are part of Python's standard library, except for Flask, and the language files are stored in the nested JSON format. Thereby, we will be making full use of the locale (via the glob and json modules) to create a multilingual analytic dashboard. includes detailed security, auto CRUD generation for your models, google charts. Here comes another great i18n guide in Python! Our complete Flask app tutorial will show you how to implement internationalization and localization in your Flask application. Simple and rapid application development framework, built on top of Flask. ![]()
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |