Today, with the increasing globalization, it has become a key factor to support multi-language content display and switching on websites for expanding the international market and serving diverse user groups.AnQiCMS as an efficient system focusing on enterprise content management, fully considers this demand, and provides a flexible and practical multilingual configuration solution.This article will discuss in detail how to configure and manage multilingual content in AnQiCMS, helping your website easily achieve globalization.
Understanding the multilingual mechanism of AnQiCMS
Before going deeper into the configuration, it is first necessary to understand the basic logic of AnQiCMS in handling multilingual content. AnQiCMS divides the multilingual feature into several levels to meet the needs of different scenarios:
- System language package:Mainly for the background management interface and some built-in front-end prompt information. This determines the operating language of the AnQiCMS system itself.
- Template static text translation:Text strings that are fixed in website templates and do not change with the article content, such as navigation menu items, copyright statements, page module titles, etc.
- Multilingual content management:Core part, involving the translation and display of actual business content such as articles, products, and single-page websites.AnQiCMS mainly supports content management of different language versions through the "multi-site" mechanism.
- Language switching and SEO optimization:Provide a mechanism for users to switch between different language versions and support the generation of content favorable for search engine recognition.
hreflang.
Understand the distinction at these levels, it helps us plan the construction process of a multilingual website more clearly.
1. Configure the AnQiCMS system language package (backend and built-in prompts)
AnQiCMS provides built-in language packages for localizing the system interface and some built-in front-end prompts. Configuring this item is relatively simple:
You can navigate to the 'Global Settings' area under the 'Background Settings' on the AnQiCMS admin interface.Here, you will find an option named "default language package".The system usually comes built-in with Chinese, English, and other languages for your selection.Once you have selected the desired language and saved, the text on the backend interface and some fixed prompts output directly by the system will be switched to that language.
It should be noted that this setting only affects the text display at the system level.The language of your articles, products, categories, and other specific business content will not change, and they need to be independently maintained through subsequent content management strategies.
2. Implement the translation of static text in templates
The website template often contains a large amount of fixed text, such as headers, footers, sidebar titles, form labels, etc.This static text also needs to be switched according to the user's selected language.AnQiCMS passes{% tr %}Translate labels and implement this using separate language files.
Create a language file:Under the AnQiCMS template directory of your, you need to create a folder named
locales.localesInside the folder, create a subfolder for each target language, for exampleen-usRepresents American English,zh-cnrepresenting Simplified Chinese. Create a.ymlfile (for exampledefault.yml), used to store the translation key-value pairs for the corresponding language.For example,
zh-cn/default.ymlMay include:"yourLocation": "您的位置" "homePage": "首页"And
en-us/default.ymlmay include:"yourLocation": "Your Location" "homePage": "Home"Use translation tags in the template:In the website template (such as
header.html,footer.htmlor any other.htmltemplate file), you can use{% tr %}Tag to call these translated texts.For example, if you need to display "Home" in the navigation bar of your website, you can write it like this:
<a href="/">{% tr "homePage" %}</a>When a user visits the website, the system will automatically load the corresponding
.ymlfile and display the correct translated text.
Chapter 3: Managing Multilingual Content (Core Strategy: Multisite)
AnQiCMS recommends and utilizes its powerful "multi-site management" feature as the core strategy for handling multilingual content.This means that you will create a separate 'site' for each language, each with its own content, settings, and independent data, but all managed by the same AnQiCMS installation instance.
Create a multilingual site:
- Plan the site structure:Firstly, decide on the URL structure of your multilingual website. Common patterns include:
- Independent domain:
yourbrand.com(Chinese),yourbrand.de(German) - Subdomain:
cn.yourbrand.com(Chinese),en.yourbrand.com(English) - Subdirectory:
yourbrand.com/cn/(Chinese),yourbrand.com/en/(English)
- Independent domain:
- Add a site:Log in to the admin panel of your AnQiCMS initial installation site, click 'Add New Site' under the 'Multi-site Management' feature.Repeat this step for each language. When creating a new site, you need to specify:
- Site Name:For example, "Chinese site", "English site".
- Website address:Corresponds to the domain name, subdomain, or subdirectory URL you have planned.
- Database name:It is recommended to use an independent database for each language site to ensure data isolation and management convenience.
- Admin account password:Set up independent backend login credentials for each site.
- Configure server reverse proxy:No matter which URL structure you choose, you need to configure the corresponding domain resolution and reverse proxy rules in your web server (such as Nginx, Apache) or Baota/1Panel panel, and correctly guide the traffic to the corresponding port of the AnQiCMS instance (if you are using Docker deployment, it corresponds to the port of the Docker container).
- Plan the site structure:Firstly, decide on the URL structure of your multilingual website. Common patterns include:
Content creation and maintenance:
- Independent management:Each language site is an independent AnQiCMS instance.This means you need to log in to the back end of each language site separately, and create and manage articles, products, categories, and single-page content in the corresponding language.For example, you created an article about 'AnQiCMS Function Introduction' on the Chinese site, and you also need to manually translate and create a corresponding 'AnQiCMS Features' article on the English site.
- Maintain content consistency:Although the content is independent, it is recommended to maintain consistency in content structure (such as category hierarchy, page model fields) between different language sites for ease of management and to enhance user experience.For example, if the Chinese site has a "News Center" category, the English site should also have a "News Center" category, and their internal content should correspond one to one.
- Content association hints (optional):AnQiCMS currently does not have a built-in content association feature to automatically link different language versions of the content.You can prompt the association of different language versions of content through custom fields or manually adding links in the article content.
IV. Implement language switching and SEO optimization
Users need an easy way to switch between language versions. At the same time, it is crucial to ensure that search engines can correctly identify the multilingual content on your website,hreflangLabel configuration is essential.
Language switcher (use
{% languages %}Tag):AnQiCMS provides{% languages %}tag to get the list of all configured multilingual sites, you can use it to build a language switcher.In your website template (usually the header or footer, etc., common parts), you can write like this: `twig {%- languages websites %} {%- if websites %}
<span>切换语言:</span> {%- for item in websites %} <a href="{{item.Link}}" title="{{item.LanguageName}}"> {%- if item.LanguageIcon %} <img src="{{item.LanguageIcon}}" alt="{{item.LanguageName}}" /> {%- else %} {{item.LanguageEmoji}} <!-- 或直接显示{{item.LanguageName}} --> {% endif %} {{item