AnQiCMS provides powerful multilingual support functionality, helping us easily promote our website content to global users.However, to correctly switch and display multilingual content, we need to understand the design approach of AnQiCMS in this aspect and configure and manage through several key steps.It mainly achieves independent content for different language versions by combining 'Multi-site Management', and provides 'Default Language Package' and 'Translation Tags' to handle the static text in system-built-in texts and templates.
Understanding the multilingual mechanism of AnQiCMS
Firstly, we need to clarify the definition and handling of "multi-language" by AnQiCMS. Forthe core content published by the user(such as articles, products, single pages, etc.)AnQiCMS tends to adopt a multi-site model.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 are that each language version of the website can have an independent domain, independent template styles, independent content, and SEO strategies, providing the greatest flexibility and manageability.
At the same time, AnQiCMS also providesBuilt-in system textsuch as backend interface hints, default messages) andhard-coded static text in templatesThe translation mechanism for values such as navigation menu items, footer copyright information with 'Contact Us', etc.This allows even a single website to switch the display language of these auxiliary texts while keeping the core content unchanged.
On a comprehensive level, the multilingual support of AnQiCMS can be broken down into the following main configuration stages:.
1. Planning and setting up a multilingual site architecture
As mentioned earlier, for content主体 in different language versions (such as, a Chinese product introduction and its corresponding English product introduction), AnQiCMS most recommends setting up an independent site for each language.
Imagine you have a main siteyourcompany.comIf you are running Chinese content, you may need to create a new siteen.yourcompany.comTo bear your English content.In the 'Multi-Site Management' feature of AnQiCMS, you can easily add and configure these new sites.Each site will have its own 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.Then, you can independently publish and manage all articles, products, pages, and other content under each language site's backend.
2. Configure the system default language package
This step is mainly for managing the AnQiCMS backend interface and certain texts displayed on the website frontend that are generated or built-in by the system.
In the AnQiCMS backend, go to the 'Global Function Settings' page under 'Backend Settings', and you will see an option for the 'Default Language Pack'.Here are multiple languages including Chinese and English to choose from.When you select and save a specific language package for a site, the admin interface of that site and some system default displayed texts (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 post in the background.It mainly affects the language display at the system level.
3. Translation of static text in the template
Many website templates include 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 (.htmlfile) and. To allow these static texts to switch according to the current site's language setting, AnQiCMS introduces "translation tags" andlocalesdirectory.
You need to create a template folder inside your folderlocales. Under this directory, create a subfolder for each target language, and the folder name should correspond to the language code (for examplezh-cnRepresents Simplified Chinese,en-usrepresents American English,jarepresents Japanese and others). Create a subfolder for each language inside,default.ymlfile.
For example, for a website that supports Chinese and English:
/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 these translation texts. For example, use<div>联系我们</div>to<div>{% tr "contactUs" %}</div>. When accessing the site in the corresponding language, the system will automatically select 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 front-end. AnQiCMS provides{% languages websites %}Label it to help you achieve this function.
This tag will retrieve the list of sites configured for multilingual in multi-site management.You can iterate over 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 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 %}
In addition to displaying the language switch link, don't forget to addhreflangTag.This can help search engines understand your website content by providing different language or regional versions, avoiding duplicate content issues, and ensuring users can access the page best suited to their language and region.<head>the following code for SEO optimization:
{% languages websites %}
{% for item in websites %}
<link rel="alternate" href="{{item.Link}}" hreflang="{{item.Language}}">
{% endfor %}
{% endlanguages %}
Hereitem.Linkwhich will point to the URLs of your various language sites,item.LanguageThen it will be the corresponding language code (for exampleen-us,zh-cn).
Summary
The multilingual support strategy of AnQiCMS is an important manifestation of its enterprise-level positioning.It isolates and manages content in different language versions through flexible multi-site management, while also providing a detailed system language package and template translation mechanism to handle auxiliary text.{% languages %}Tags for implementing front-end switching andhreflangTags for SEO optimization, you can build a powerful and globally user-friendly multilingual website.
Common Questions (FAQ)
1. Does AnQiCMS automatically translate my articles or product content?Will not.AnQiCMS uses a multi-site management mode with 'content isolation' to handle the core content of different language versions.This means 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.
If I only run one website but want certain fixed texts (such as the copyright statement in the footer, navigation links) to support language switching, is it possible?Can be.In this case, you can use the multi-site feature to differentiate content subjects, but you can still take advantage of the 'Configure system default language pack' and 'Static text translation in templates' features.localesDirectory and{% tr %}Translate labels to translate static text. As for language switching,{% languages websites %}Create a link 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, and the content of the articles you publish in the background will remain in the original language.
How to determine which page is displayed in the template?