問題
- ユーザーが誤って他の言語を選択した場合、URLから抜け出せなくなり、すべてのリンクが使えなくなる。 ユーザーは/en/を手動で入力するか、キャッシュをクリアして英語に戻らなければならない。
環境
- DXP 7.4
解像度
-
デフォルトのロケールに戻す正しい方法は、URLからロケールコードを削除して正しい状態に戻すか、この機能を制御する以下のポータル・プロパティを追加(0に設定)してみることです。
# Set this to 0 if the locale is not automatically prepended to a URL. This
# means that each URL could potentially point to many different languages.
# For example, the URL http://localhost:8080/web/guest/home could then be
# viewed by users in many different languages.
#
# Set this to 1 if the locale is automatically prepended to a URL when the
# requested locale is not the default locale. This means that each URL
# points to just one language. For example, the URL
# http://localhost:8080/web/guest/home would point to the default language.
# The URL http://localhost:8080/zh/web/guest/home and
# http://localhost:8080/zh_CN/web/guest/home would both point to the Chinese
# language.
#
# In cases where the prepended locale is "zh" and not the complete locale
# "zh_CN", then the full locale returned will be based on the order in which
# the locales appear in the property "locales". If "zh_CN" appears before
# "zh_TW", then "zh" will be a short hand for "zh_TW".
#
# The default language is set in system.properties with the properties
# "user.country" and "user.language".
#
# Set this to 2 if the locale is automatically prepended to every URL. This
# means that each URL points to just one language.
#
# Set this to 3 if the locale is automatically prepended to a URL when the
# requested locale is not the default user locale. In the case of guest
# users, the behavior is the same as having a value of 1.
#
# Note that each language requires an entry in the property "locales" and a
# servlet mapping in web.xml for the I18n Servlet.
#
# Env: LIFERAY_LOCALE_PERIOD_PREPEND_PERIOD_FRIENDLY_PERIOD_URL_PERIOD_STYLE
#
locale.prepend.friendly.url.style=3 -
何らかの理由で最初の解決策で問題が解決しない場合は、ロケール・インスタンスで他の言語が利用できない可能性があります。その場合は、次のプロパティを
true
:に設定してみてください。
このプロパティが#
# Set this to false to return an HTTP 404 status code and page if the
# requested URL includes a locale that is not available among the locales
# set in the "locales" and "locales.beta" properties.
#
# For example, if Spanish is not one of the available locales and
# http://localhost:8080/es/web/guest is requested, then a 404 error code and
# page is returned.
#
# This can improve SEO since it avoids duplicated pages, if in the
# installation, there are a set of defined locales available.
#
# Env: LIFERAY_LOCALE_PERIOD_USE_PERIOD_DEFAULT_PERIOD_IF_PERIOD_NOT_PERIOD_AVAILABLE
#
locale.use.default.if.not.available=falsetrue
の場合、利用できないロケールに切り替えようとすると、ポータルは自動的にデフォルトロケールにリダイレクトします。
追加情報
会員限定記事
Liferay エンタープライズ サブスクリプションをお持ちのお客様は1500件を超えるベストプラクティス、トラブルシューティング、その他のソリューション記事を閲覧できます。ログインすると、記事全体をお読みいただけます。
ログイン