antvis / G6VP

G6VP is an online visual analysis tool for graphs and a low-code platform for building graph applications.

Home Page:https://insight.antv.antgroup.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

G6VP page starts in Chinese when first opened

RackweLLizm opened this issue · comments

@pomelo-nwu

When I first open the G6VP page, it starts in Chinese.
Then I immediately refresh the page and see that it is in English.

I noticed that in Cookies it changed the x-hng value to Lang= en-US.

I set this immediately when the project is first opened, before the user even gets to the g6Vp page.

import GISDK, { LANGUAGE_KEY_NAME, utils } from '@antv/gi-sdk';
import locale from '@aligov/global-locale';

locale.setLang(LANGUAGE_KEY_NAME.EnUs);

Also when starting GISDK, I passed a parameter to the locales property as below.

<GISDK
            //@ts-ignore
            config={GI_PROJECT_CONFIG}
            assets={ASSETS as any}
            services={services}
            locales={{{language:LANGUAGE_KEY_NAME.EnUs}}
            id={baseId}
          >
          </GISDK>

But the result did not change. The page always opens in Chinese when first opened. When you reload (f5) it becomes English.

How can I solve this problem.

function update() {
  var _locale$getLocale = locale.getLocale(),
    lang = _locale$getLocale.lang ? _locale$getLocale.lang : "en-US";
  language = lang ? lang : "en-US";
  intl = stringFormat.init(lang, strings, {
    name: 'sdk'
  });
}

@AntV\gi-sdk\es\i18n
@AntV\gi-advance,gi-basic ....

if I update the update() function in index.js in the i18n folder of all of them as above, this problem is solved.

For now, I will share a hard code solution when I find a better one.

This problem occurs because the page is undefined when it is first loaded.