Django makemessages. mo files that are used by gettext.
Django makemessages 在 Django 中,makemessages 是一个命令行工具,用于收集项目中的可翻译文本,并生成对应的翻译文件。 通过这个命令,我们可以方便地管理应用程序的多语言支持。 如何使用 makemessages 命令? 使用 makemessages 命令非常简单,只需要在终端中运行以下命令: 该命令会扫描项目中的源代码文件,搜索特定类型的翻译字符串,并将它们提取到一个. _po files for each language: django-admin makemessages -l es for Spanish, and django-admin makemessages -l fr for French. It creates (or updates) a message file in the conf/locale (in the django tree) or locale (for projects and applications) directory. mo files that are used by gettext. Feb 11, 2016 · project + django + dbindexer + registration + myapp + locale + templates I have strings to localize in templates directory, and in the myapp directory. django-admin. py. My 使用 makemessages 命令. py makemessages -l en --ignore django\* from the project dir it crawl through all the directories of the project, including django, so I get a quite big po file. Sep 8, 2014 · I recommend to use django-rosetta for this purpose, which is a Django application that eases the translation process of your Django projects. settings to make the compiler process all the directories in your LOCALE_PATHS setting. Nov 16, 2023 · Run the makemessages command to update your _. And you use django-admin compilemessages to produce the binary . You can also run django-admin compilemessages--settings=path. po文件是gettext工具使用的翻译文件格式,其中包含了原始文本和翻译文本。 默认情况下,makemessages 会搜索项目中所有的应用程序,并为每个应用程序生成一个. In each . py 是在每个 Django 项目中自动创建的。 它与 django-admin 执行相同的操作,但还设置了 DJANGO_SETTINGS_MODULE 环境变量,使其指向您项目的 settings . po文件。 但是,这个命令没有直接提供一种办法来处理位于 site-packages 目录下的应用程序的翻译。 django-admin makemessages Runs over the entire source tree of the current directory and pulls out all strings marked for translation. Django 的 makemessages 命令及如何使用 javascript (xgettext) 在本文中,我们将介绍 Django 中的一个重要命令——makemessages,并且讨论如何使用 JavaScript (xgettext) 来处理多语言支持。 阅读更多:Django 教程 什么是 makemessages 命令? makemessages 是 Django 中的一个 Django 如何使用django-admin. Using a non-English base Feb 11, 2016 · When I run python manage. A trick is for example to create some fake (=unused in your project) files (code or template) in your project where you put the strings you want to re-translate in your own po files. py makemessages --all Everything should work now To create message files, you use the django-admin makemessages tool. Extended version of Django's makemessages command that exposes selected GNU gettext tools options and adds new custom options, which further simplify message detection and translation files management. py makemessages --all命令来提取和管理Django项目中的翻译字符串。 阅读更多:Django 教程 什么是 makemessages 命令 makemessages 是 Django 中为多语言支持 django-admin makemessages Runs over the entire source tree of the current directory and pulls out all strings marked for translation. It creates (or updates) a message file in the conf/locale (in the Django tree) or locale (for project and application) directory. Jan 6, 2024 · Because the makemessages command will only extract strings from your project, not the strings from Django built-in code or templates. django-admin 是 Django 用于管理任务的命令行实用程序。 本文档概述了它可以做的所有事情。 另外,manage. Step 4: Translate and handle plural forms in . Elle crée (ou met à jour) un fichier de messages dans le répertoire conf/locale (pour l’arborescence Django) ou locale (pour les projets et Django makemessages 命令不能创建新添加的语言. po file: Dec 12, 2023 · django-admin makemessages 遍历当前目录下的整个源码树,并提取所有标记为翻译的字符串,并在 conf/locale(在 Django 树中)或 locale(对于项目和应用程序)目录下创建(或更新)一个消息文件。 makemessages ¶ django-admin makemessages ¶ Parcourt l’entier de l’arborescence de code source à partir du répertoire actuel et extrait toutes les chaînes marquées pour la traduction. Django国际化简介 django-admin 和 manage. When I run python manage. 在本文中,我们将介绍如何使用Django的makemessages命令来国际化您的应用程序,并解决一个常见的问题:makemessages命令不能创建新添加的语言的翻译文件的情况。 阅读更多:Django 教程. May 8, 2025 · Extended version of Django's makemessages command that exposes selected GNU gettext tools options and adds new custom options, which further simplify message detection and translation files management. py makemessages --all 在本文中,我们将介绍如何使用Django命令行工具中的django-admin. Feb 27, 2024 · $ django-admin makemessages -d djangojs -l # generates message file for js code $ django-admin compilemessages # compiles the generated file The first command will generate a new djangojs. po file, you will find entries for the singular and plural forms. to. po files. django-admin makemessages ¶ Runs over the entire source tree of the current directory and pulls out all strings marked for translation. Django 提供了一个名为 makemessages 的命令,它可以自动扫描我们的代码中的字符串,并生成相应的翻译文件。下面是使用 makemessages 命令的基本步骤: 激活虚拟环境:首先,我们需要激活包含我们的 Django 应用程序的虚拟环境。 Django makemessages 在Django中,makemessages命令是用来提取项目中所有的字符串,并将其翻译成不同语言的工具。 这对于国际化和本地化非常重要,因为它可以让你的网站支持多种语言,为不同的用户提供更好的体验。 May 8, 2025 · django-extended-makemessages. My strings from the templates are there, along with all of the strings from django directory. po文件中。 . rqckuujbsxnfyrnkovuvhyvxkhusfcahaagnfulnunbigagnluqpvkq