AnQiCMS provides powerful multilingual support features, helping us easily promote our website content to global users.However, in order to switch and display multilingual content correctly, we need to understand the design approach of AnQiCMS in this aspect and configure and manage it through several key steps.It mainly achieves independent content for different language versions by combining 'Multi-site management', and at the same time provides 'Default language package' and 'Translation tags' to handle the static text in the system built-in text and templates.
Understanding the multilingual mechanism of AnQiCMS
Firstly, we need to clarify the definition and handling of "multilingual" by AnQiCMS. ForCore content published by the user(such as articles, products, single pages, etc.), AnQiCMS tends to adopt a multi-site mode.This means that if you want to provide an English translation version of your Chinese article, the usual practice is to create or translate this article on a dedicated English site.The benefits of this design lie in the fact that each language version of the website can have its own domain name, its own template style, its own content, and SEO strategy, providing the greatest flexibility and manageability.
At the same time, AnQiCMS also provides forsystem built-in text(such as background interface hints, default messages) andhard-coded static text in templates(such as the translation mechanism for navigation menu items, footer copyright information such as "Contact Us", etc.)This allows even a single website to switch the display language of these auxiliary texts while keeping the core content unchanged.
In summary, the multilingual support of AnQiCMS can be decomposed into the following main configuration stages:
1. Plan and build a multilingual site architecture
As mentioned earlier, for different language versions of the content subject (for example, a Chinese product introduction and the corresponding English product introduction), AnQiCMS most recommends setting up an independent site for each language.
Imagine you have a main siteyourcompany.comIf you are operating Chinese content, you may need to create a new siteen.yourcompany.comCarry your English content. In the "Multi-site Management" feature of AnQiCMS, you can easily add and configure these new sites.Each site will have an independent database, file storage, and backend management entry, but they are all efficiently managed by the same AnQiCMS instance.
When creating a new site, you need to specify a unique domain name or subdomain for each language site and configure the database and back-end administrator account for it.Later, you can independently publish and manage all articles, products, pages, and other content under each language site's backend.
2. Configure the default system language package
This step is mainly to manage the AnQiCMS backend interface and some text display languages generated or built-in on the website frontend.
In the AnQiCMS backend, go to the page under "Backend Settings" and "Global Function Settings", where you will see an option for the "Default Language Pack".Here is built-in Chinese and English and other languages for selection. After you have selected and saved a specific language package for a site, the background management interface of the site and some system default displayed text (such as, if your template directly calls the system built-in "Previous", "Next" navigation text) will be displayed according to the selected language.
It is important to remember,This setting will not automatically translate the specific content of articles, products, or pages you publish in the background. It mainly affects the language display at the system level.
3. Translation of static text in the template
Many website templates contain some fixed and unchangeable text, such as "Home", "About Us", "Contact Us", "Privacy Policy", etc. This text is usually not dynamically generated by the backend content management system, but is written directly in the template file (.htmlIn the file. In order for these static texts to also be switched according to the current site's language settings, AnQiCMS has introduced translation tags andlocalesDirectory.
You need to create one in your template folderlocalesdirectory. Under this directory, create a subfolder for each target language, the folder name should correspond to the language code (for examplezh-cnrepresenting Simplified Chinese,en-usRepresents American English,jaRepresents Japanese and others.). Create one in each language subfolderdefault.ymlfile.
For example, for a website that supports Chinese-English bilingualism:
/template/您的模板名/locales/zh-cn/default.yml"yourLocation": "您的位置" "contactUs": "联系我们"/template/您的模板名/locales/en-us/default.yml"yourLocation": "Your Location" "contactUs": "Contact Us"
You can use it in your template file.{% tr "键名" %}Label to reference these translation texts. For example, to<div>联系我们</div>changed to<div>{% tr "contactUs" %}</div>. When accessing a site in the corresponding language, the system will automatically retrieve from the respectivedefault.ymlLoad and display the correct translation text in the file.
4. Implement the front-end language switching function.
In order for users to switch between different language sites, you need to provide a language switcher on the website frontend. AnQiCMS provides{% languages websites %}Tag to help you achieve this function.
This tag will retrieve the list of sites configured for multilingual in multi-site management.You can iterate through this list in the template to generate a link for each language site, and users can click these links to jump to the corresponding language website.
For example, you can use it in your template file (usually the common part of the header or footer):
{% languages websites %}
{% if websites %}
<div>
<span>切换语言:</span>
{% for item in websites %}
<a href="{{item.Link}}">
{% if item.LanguageIcon %}
<img src="{{item.LanguageIcon}}" alt="{{item.LanguageName}}" />
{% else %}
{{item.LanguageEmoji}} <!-- 如果没有图标,可以显示语言对应的 Emoji 符号 -->
{% endif %}
{{item.LanguageName}}
</a>
{% endfor %}
</div>
{% endif %}
{% endlanguages %}
Don't forget to add language switch links for SEO optimization.hreflangTags. This helps search engines understand that your website content provides different language or regional versions, avoids duplicate content issues, and ensures that users can access the page most suitable for their language and region.You can<head>Add similar code to the region.
{% languages websites %}
{% for item in websites %}
<link rel="alternate" href="{{item.Link}}" hreflang="{{item.Language}}">
{% endfor %}
{% endlanguages %}
Hereitem.LinkIt will point to your various language site URLs.item.LanguageIt corresponds to the language code (for exampleen-us,zh-cn)
Summary
The multi-language support strategy of AnQiCMS is an important manifestation of its enterprise-level positioning.It isolates and manages content for different language versions through flexible multi-site management, and provides a meticulous system language package and template translation mechanism to handle auxiliary text. Combining{% languages %}Tags to implement front-end switching andhreflangTags for SEO optimization, you can build a powerful, globally user-friendly multilingual website.
Frequently Asked Questions (FAQ)
1. Can AnQiCMS automatically translate my article or product content?I don't know. AnQiCMS uses a 'content isolation' multi-site management model to handle the core content of different language versions.This means that you need to maintain a separate site for each language and create, upload, or translate your articles, product descriptions, and other content on these sites.The system will not automatically translate content.
2. Can I run only one website but want some fixed text (such as footer copyright statements, navigation links) to support language switching?Can be. In this case, you can not use the multi-site feature to distinguish the main content, but you can still take advantage of the two features of 'configuring the system default language package' and 'translation of static text in templates'.You can configure in your templatelocalesTable of contents and{% tr %}Label to translate static text. As for language switching, you can use{% languages websites %}Create a link pointing to a different language path for the tag, or manually control the link logic, but please note that only the static text in the template and the system built-in text are switched at this time, while the content of the articles you publish in the background will remain in the original language unchanged.
How to determine which type of page is displayed in the template