pierrejeambrun commented on code in PR #54008:
URL: https://github.com/apache/airflow/pull/54008#discussion_r2248191568
##########
airflow-core/src/airflow/ui/src/i18n/config.ts:
##########
@@ -37,13 +37,17 @@ export const supportedLanguages = [
export const defaultLanguage = "en";
export const namespaces = ["common", "dashboard", "dags", "admin", "browse",
"assets", "components"] as const;
+const baseHref = document.querySelector("head > base")?.getAttribute("href")
?? "";
+const baseUrl = new URL(baseHref, globalThis.location.origin);
+const basePath = new URL(baseUrl).pathname.replace(/\/$/u, "");
+
void i18n
.use(Backend)
.use(LanguageDetector)
.use(initReactI18next)
.init({
backend: {
- loadPath: "/static/i18n/locales/{{lng}}/{{ns}}.json",
+ loadPath: `${basePath}/static/i18n/locales/{{lng}}/{{ns}}.json`,
Review Comment:
Nit, you should be able to construct the full URL using the `new URL`
construct, that will remove duplicates `/` etc so you don't have to use the
above regexp to remove it.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]