In today's globalized business environment, whether a website can support multi-language content publishing and switching has become an important standard for measuring its internationalization capability.安企CMS(AnQiCMS)as a high-efficiency content management system, fully considers this need, and provides users with a flexible and practical multilingual content solution.
To understand how AnQiCMS supports multilingual, we can look at two main aspects: one is the management and publication of core content such as articles, products, and pages; the other is the translation and switching of fixed text in website templates (such as navigation names, button texts).
The publication and management of multilingual content: multi-site strategy
The core mechanism of AnQiCMS handling multilingual core content is its powerfulMulti-site managementFunction. When you need to provide independent content for users of different languages, the most direct and efficient method is to use this function.
Specifically, you can create a separate site for each target language. For example, if your business needs to support Chinese, English, and Japanese, you can set up three sites:
- Main site (e.g.)
www.yourdomain.com, for Chinese content) - English site (e.g.)
en.yourdomain.com) - Japanese site (e.g.)
jp.yourdomain.com)
Each site has its own database, content, and template configuration, but can share the same AnQiCMS program.This means that the content of each language will be independently published and managed on its dedicated site, without interference, ensuring the accuracy and professionalism of the content.When operating in the background, you can log in to the corresponding language site backend and add, edit, and publish articles, products, or single pages just like managing a single site.The advantage of this method is that it allows content in different languages to maintain a high degree of flexibility in structure, SEO optimization, and operational strategy, avoiding the confusion that may arise from managing multiple languages in a single content library.
It is worth noting that the "Default Language Package" option in the global function settings mainly affects the language of the background management interface and some built-in system prompts.It does not automatically translate the core content of your website, such as articles and products.Therefore, we still need to maintain separate sites for the core content of different languages.
Front-end multilingual switching and display
On the website front-end, allowing visitors to easily switch languages is the key to improving user experience. AnQiCMS provides a very practical template tag:{% languages %}.
This label will automatically retrieve all the multilingual site information you have configured in the AnQiCMS backend, including the language name, language code, link address of the site, as well as the language emoticons or icons that can be used for display.You can use this tag in the website template, such as in the header or footer, to build a dynamic language switcher.
The following is a commonly used code example, demonstrating how to generate language switch links:
{%- 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}}
{% endif %}
{{item.LanguageName}}
</a>
{%- endfor %}
</div>
{%- endif %}
{%- endLanguages %}
This code will iterate over all configured multilingual sites and generate a switch option for each site containing links and language names (or icons, emojis).Users can click to jump to the corresponding language website in English.
In addition, to better serve international users and optimize search engine rankings, it is important to configure correctly:hreflangtags.hreflangTags can tell search engines that a specific page is a substitute version for pages in other languages or regions, thus avoiding duplicate content issues and improving international SEO performance. You can also take advantage of{% languages %}Label to dynamically generate these important tags.hreflangThese tags are usually placed in HTML.<head>area:
{%- languages websites %}
{%- for item in websites %}
<link rel="alternate" href="{{item.Link}}" hreflang="{{item.Language}}">
{%- endfor %}
{%- endLanguages %}
Translation of fixed text in the template:{% tr %}tags
In addition to the core content, there are many fixed text in the website template, such as "HomeThis also needs to be translated according to the current language setting of the website to provide a complete localized experience.{% tr %}(translate) Tag.
Use{% tr %}Some simple configurations are required for the tag:
- Create a folder named in your template root directory.
locales. - In
localesInside the folder, create a subdirectory for each target language, such asen-us(English),zh-cn(Simplified Chinese),ja(Japanese), - In each language subdirectory, create one or more
.ymlfiles (for example)default.yml),for storing the translation key-value pairs of the language.
For example,zh-cn/default.ymlThe file may contain:
"yourLocation": "您的位置"
"homePage": "首页"
"contactUs": "联系我们"
The correspondingen-us/default.ymlfile may contain:
"yourLocation": "Your Location"
"homePage": "Home"
"contactUs": "Contact Us"
In the places where you need to use these translated texts in the template, you just need to use{% tr "键名" %}the format.
<a href="/">{% tr "homePage" %}</a>
<p>{% tr "contactUs" %}</p>
When the website visitor switches language, AnQiCMS will automatically select the corresponding language based on the current site language setting..ymlRead and display the corresponding translated text from the file, ensuring that the text information on the front-end page is fully adapted to the target language.
Summary
AnQiCMS combines flexibility withMulti-site managementThe strategy to carry the core content of different languages, utilizing{% languages %}tagsTo achieve front-end language switching and SEO optimization, and to make use of{% tr %}tagsManage the translation of static text in the template.This set of comprehensive and well-defined mechanisms provides a solid foundation for enterprises and content operators to build efficient and professional global multi-language websites, facilitating cross-border content dissemination.
Common Questions and Answers (FAQ)
1. How to create and manage content for different languages in AnQiCMS?You need to use the "Multi-Site Management" feature of AnQiCMS. Create an independent site for each target language (for exampleen.yourdomain.com/fr.yourdomain.com)。Then, log in to the backend of each site, independently publish and manage the core content of the language, such as articles, products, single pages, etc.This method ensures that the content is independent across different language versions, making it easier for refined operations and SEO.
2. Will changing the 'Default Language Pack' in the background 'Global Feature Settings' translate my website content to English?Will not.Global function settings of "Default Language Pack" mainly affects the display language of AnQiCMS backend management interface, as well as some built-in system prompts and date formats, etc.It does not automatically translate the core content (such as article titles, body text, product descriptions, etc.) that has already been published on your website. This content needs to be managed by manually inputting or translating it in the corresponding language site.
3. How to translate fixed button or navigation text such as 'Submit' or 'Home' in website templates?For the fixed text in the template that does not change with the article content, you can use AnQiCMS's{% tr "键名" %}translation tags. First, create in the template directorylocalesFolder, and create subdirectories for each language within it (such asen-us), then create.ymlfiles (such asdefault.yml), and write the key-value pairs in translation. For example,"homePage": "Home". After that, use it in the template.{% tr "homePage" %}Call it, the system will automatically display the correct translation based on the current website's language settings.