How to implement multi-language content switching and display on AnQiCMS website?

Under the wave of globalization, website multilingual support has become a necessary condition for enterprises to expand into international markets.AnQiCMS as an enterprise-level content management system, fully considers this requirement and provides a set of efficient and flexible solutions to help users easily switch and display multi-language content.

Multi-language implementation logic of AnQiCMS

AnQiCMS implements the core strategy of multilingual content switching and display, which is based on its powerful "multi-site management" function.It does not use an automatic translation mode, but treats each language version as an independent website instance for management.This means that your Chinese website, English website, Japanese website, and so on, will all be independent sites in the AnQiCMS backend, each having its own domain (or subdomain, subdirectory structure), content database, and template configuration.

In the system settings, although AnQiCMS provides the option of "default language package" to switch the display language of the background management interface or the built-in少量 system text (such as some prompt information) of the website, this is limited to the system level.For the actual content published on the website, such as articles, products, category names, etc., AnQiCMS requires you to independently enter and maintain the corresponding content for each language site.This design philosophy ensures the accuracy, professionalism, and relevance of content across different language versions, avoiding semantic deviations that may arise from machine translation.

Set up and configure a multilingual website

To implement a multilingual website, you first need to use AnQiCMS's 'Multi-site Management' feature.In the background, you can create multiple site instances, each instance corresponding to a target language.For example, you can create a main site for Chinese content, and then create an English site, a Japanese site.en.yourdomain.comorjp.yourdomain.com),and configure the corresponding database.

After completing the site creation, you can log in to the backend of each language site, independently publish and manage content according to the characteristics of the language and the needs of users.This means that your English article needs to be manually translated and published on the English site, while Japanese product information is published on the Japanese site, and so on.This independent management approach allows you to localize content based on the market characteristics of different regions, and even adjust marketing strategies and SEO keywords.

How to implement language switching and display on the front end

On the website frontend, users will usually see a language switcher that allows them to select their preferred language. AnQiCMS provides{% languages websites %}Such template tags help you easily build such a toggle feature.

For example, in the public header or footer of your website template, you can insert the following code to generate a language switch menu:

{%- 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 %} {# 否则显示语言Emoji或名称 #}
        {{item.LanguageEmoji}} {{item.LanguageName}}
        {% endif %}
    </a>
    {%- endfor %}
</div>
{%- endif %}
{%- endlanguages %}

This code will loop through all the language sites you create in the background and generate a toggle button for each site with its link, language name, and optional icon or Emoji.When a user clicks on a link of a language, it will jump to the corresponding website instance of that language.

Once a user accesses a specific language site via the language switcher, all labels used for content display on the page, such as retrieving the article list,archiveList, to obtain category detailscategoryDetailThe content will be automatically extracted from the database of the current language site.This means you do not need to write different content calling logic for each language, AnQiCMS will automatically identify the language environment of the current site and display the corresponding content.

SEO optimization: Hreflang tag

For the SEO of multilingual websites,hreflangThe label is crucial.It can inform search engines which pages are alternative language versions of the same content, thus avoiding duplicate content issues and ensuring that search engines display the correct language content to users in the respective language regions.

AnQiCMS also supports dynamic generation in templateshreflangtags. You can add the following code in the website's<head>area:

{%- languages websites %}
{%- for item in websites %}
<link rel="alternate" href="{{item.Link}}" hreflang="{{item.Language}}">
{%- endfor %}
{%- endlanguages %}

This code will generate alinkLabel, specify the alternative language version and the corresponding URL, thereby effectively enhancing the performance of multi-language websites in international search engines.

Summary

AnQiCMS through its unique multi-site management function, provides a powerful and flexible solution for switching and displaying multi-language content.Although the translation and entry of the content require manual completion, this model ensures the quality of localization and SEO advantages.From the background site configuration to the front-end language switcher and SEO optimization, AnQiCMS provides comprehensive support to enable your website to better serve global users.


Common Questions (FAQ)

1. Does AnQiCMS support automatic translation of content?AnQiCMS currently does not provide a feature for automatic translation of content.It adopts an independent site content management mode, you need to manually translate and enter the corresponding content for each language site.This method ensures the quality and localization accuracy of the content.

2. How to set up independent domain names or subdomains for different language versions?In the "Multi-site Management" feature of AnQiCMS backend, you can specify a separate domain name or subdomain for each new language site created.Before this, you need to correctly resolve these domain names and point them to the installation directory of AnQiCMS at your server (such as Nginx, Apache) or DNS service provider, ensuring they can be accessed normally.

3. Will the website URL change after language switching?It will be alright.Since AnQiCMS treats each language version as an independent website instance, language switching usually causes the URL to change.yourdomain.comSwitching to the English site may change toen.yourdomain.comOr, it can be according to your configuration,yourdomain.com/en/This subdirectory structure is clear and beneficial for search engine recognition and user experience.