Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

G6VP page starts in Chinese when first opened #537

Closed
RackweLLizm opened this issue Oct 20, 2023 · 1 comment
Closed

G6VP page starts in Chinese when first opened #537

RackweLLizm opened this issue Oct 20, 2023 · 1 comment

Comments

@RackweLLizm
Copy link
Contributor

RackweLLizm commented Oct 20, 2023

@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.

@RackweLLizm
Copy link
Contributor Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant