AnQi CMS, as an enterprise-level content management system developed based on the Go language, it is committed to providing efficient and customizable solutions for small and medium-sized enterprises and content operation teams.In today's global internet environment, multilingual support is no longer an optional feature, but a core function for expanding the market and enhancing user experience.When we talk about the multilingual settings of AnQiCMS,localesThe folder undoubtedly plays a crucial role, it is the key to realizing the translation of static text in the front-end template.

localesThe folder plays a core role in the AnQiCMS multilingual settings.

In short,localesThe folder is the 'translator' at the AnQiCMS template level.It is specifically used to manage all the static text content that needs to be translated into multiple languages in the front-end template of a website, such as navigation menu items, button text, page titles, prompt information, copyright statements, and other user interface (UI) elements.The static text in these templates, which is different from the dynamic content stored in the database (such as articles, product details, category names, etc.), requires a unified and efficient translation mechanism, whilelocalesThe folder is created for this purpose.

Imagine that your website needs to support Chinese, English, and French.If you add a language, you will need to manually modify the corresponding text in the template file, which will be a huge and error-prone task.localesA folder is introduced with a set of key-value translation system to decouple these static texts from the template code. In this way, regardless of how many languages your website needs to support, you do not need to change the template structure, just inlocalesAdd or modify the translation file in the folder to easily switch the interface language.

localesExplanation of the folder's working mechanism.

AnQiCMS'localesThe folder is usually located in the root directory of the template theme you are using (i.e./template/您的模板名/locales). Inside this folder, you will create a separate subdirectory for each supported language, such aszh-cnUsed for Simplified Chinese,en-usUsed for American English,frUsed for French, etc. Each language subdirectory will contain one or more YAML formatted translation files, usually nameddefault.yml.

These YAML files store a series of key-value pairs (Key-Value Pair).Among them, 'Key' is a unique identifier referenced in the template, and 'Value' is the translation text of the key in a specific language.For example, inzh-cn/default.ymlin, you may define"yourLocation": "您的位置"; while inen-us/default.ymlThis corresponds to the definition of"yourLocation": "Your location".

When you need to display this text in the AnQiCMS template file, you no longer write "Your location" directly, but use the AnQiCMS provided{% tr "key" %}Translate label. For example, you will write in the template{% tr "yourLocation" %}. When a user visits your website, AnQiCMS will automatically search for the corresponding language subdirectory based on the user's current language setting (or the website's default language configuration)default.ymlfile, extract outyourLocationThe value corresponding to the key is dynamically displayed on the web page. This way, even if your website has dozens of language versions, all UI text switching will be seamless and automatic.

localesCollaboration with AnQiCMS overall multilingual strategy

It is worth noting that,localesThe folder is mainly responsible for the translation of static text in the template. AnQiCMS also supports wider multilingual needs through other mechanisms.For example, in the "Global Settings" in the background, there is an option for the "Default Language Pack".This setting affects some built-in information display of the AnQiCMS system, such as operation prompts on the background management interface, system messages, etc., it is related tolocalesThe translated content of the folder in the frontend template is different.

In addition, AnQiCMS also supports multi-site management features, allowing independent domains and content to be configured for sites of different languages, in conjunction with the Hreflang tag (which can belanguagesLabel generation), to implement a multilingual site structure friendly to search engines.localesThe folder is an indispensable part of this overall multilingual strategy, ensuring that users can not only see the translated dynamic content when browsing different language versions of the site but also experience a fully localized user interface.

In summary,localesThe folder is the core mechanism of AnQiCMS for implementing the front-end multilingual interface translation.It greatly simplifies the development and maintenance of multilingual websites through structured file management and simple template tags, providing website operators with great flexibility and convenience, enabling the website to face global users in a more friendly and professional manner.


Frequently Asked Questions (FAQ)

1.localesIs the folder only used to translate the text in the front-end template?Yes,localesThe folder is mainly used for managing and translating the hard-coded static text content in the AnQiCMS front-end template, such as navigation menus, button labels, copyright information, and other user interface elements.For articles, product introductions, category names, and other dynamic content, you usually need to create or edit independent data entries for each language in the background, or manage them through the multi-site feature.

2. The default language package setting of AnQiCMS backend andlocalesWhat is the difference between the folder?The default language package in the "Global Settings" of AnQiCMS mainly affects the system's built-in prompts, back-end management interface text, etc., and it changes the core language display provided by the AnQiCMS program itself. AndlocalesThe folder is responsible for translating what you use in the custom template file{% tr "key" %}Tag introduces the text content defined by yourself. Both serve different levels of translation and together improve the multilingual environment of AnQiCMS.

3. If my template does not use{% tr "key" %}Tags, thenlocalesWill the folder still work?No.localesThe translation content in the folder will only take effect if the template file passes{% tr "key" %}The tag will be loaded and applied when explicitly called. If the static text in your template has not been{% tr %}Label enclosed, AnQiCMS will not attempt to translate it, but will directly display the original text in the template. Therefore, to implement a multilingual interface, it is necessary to use the template correctly{% tr %}.