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

Method to set english as the default language? #430

Closed
3 of 6 tasks
BrianGilbert opened this issue Apr 5, 2020 · 11 comments
Closed
3 of 6 tasks

Method to set english as the default language? #430

BrianGilbert opened this issue Apr 5, 2020 · 11 comments

Comments

@BrianGilbert
Copy link

BrianGilbert commented Apr 5, 2020

The type of this issue / Issue 类型

  • Feature request / 新特性需求
  • Bug report / Bug 报告

Not introduced by ECharts / 非 ECharts 本身问题

Problems about ECharts itself are not handled in this repo. / 本 repo 不负责处理 ECharts 本身的问题。

  • I've checked it's not a problem of ECharts itself. / 我已检查过,这个问题非 ECharts 本身的问题。

Details / 详情

ECharts currently has no way to set the language at runtime, it needs to be selected at the build stage, reference:
apache/echarts#7451 (comment)

I found the following note on the echarts repo that may give a way to set it, but I can't figure where this would be added when using vue-echarts:
apache/echarts#12037 (comment)

How are you importing Vue-ECharts? / 你是如何引入 Vue-ECharts 的?

The version of Vue-ECharts you are using / Vue-ECharts 的版本

4.7.0

Reproduction link / 复现链接

For bug reports, please provide the steps to reproduce and if possible a minimal demo of the problem. Please paste the link to your CodeSandbox demo below:

对于 Bug 报告,请在下面提供复现的步骤,最好是最小化的能够重现问题的 demo。请在下方贴入在 CodeSandbox 上 demo 的链接:

@Justineo
Copy link
Member

Justineo commented Apr 6, 2020

You can try add a webpack alias that map echarts/lib/lang to echarts/lib/langEN. See how to extend webpack config in Nuxt here.

@Justineo Justineo closed this as completed Apr 6, 2020
@Decipher
Copy link

Decipher commented Apr 7, 2020

@Justineo

Unfortunately, as the vue-charts module is importing from the source of echarts instead of the bundle, the only way that I can make an alias work is with the following, potentially dangerous code:

config.resolve.alias['../lang'] = path.resolve(__dirname, 'MYFILE')

It would be preferable if I didn't have to target the file so loosely, as it could have negative effects on unrelated code.

I have not dealt with webpack aliases before, so I may be missing something obvious, but thus far changing the language seems quite inaccessible.

@Decipher
Copy link

Decipher commented Apr 8, 2020

@Justineo Can this be re-opened, the solution is not viable for real world usage.

@Justineo Justineo reopened this Apr 9, 2020
@Decipher
Copy link

Decipher commented Apr 9, 2020

@Justineo

Based off my looking into this issue, it appears the main problem is that vue-echarts uses the source (echarts/lib/echarts) rather than the dist. However, this is still likely the preferred choice to reduce the size of the bundle.

There was/is also an issue with the dist version of the english translation, but @BrianGilbert has pushed a fix for this (apache/echarts#12387). However, until there's a new release, this fix isn't overly helpful yet.

I'm not 100% certain what the best solution is at the moment, but my gut feeling is I'm either going to have to use a fork of vue-echarts and/or a fork of echarts.

Any thoughts on best to deal with this issue would be appreciated.

@BrianGilbert
Copy link
Author

BrianGilbert commented Apr 9, 2020

I think a lang config option in mainline echarts would be the best long term solution, there is already an open issue requesting it: apache/echarts#7451

@Justineo
Copy link
Member

Justineo commented Apr 9, 2020

I'll discuss this with the ECharts team later and try to figure out a solution for this.

@Justineo
Copy link
Member

Hi folks, it seems that they plan to provide better language support for echarts@5 which will probably shipped around the end of June.

@stereokai
Copy link

stereokai commented Jul 26, 2020

@Justineo well, it's already July and echarts@5 nowhere near to being released

Can we address this for now?

@Decipher how did you solve this eventually?

@dantimofte
Copy link

Hello, in case it helps someone until a proper solution is released this is my workaround:
I added the following line in my cicd pipeline:

mv node_modules/echarts/lib/langEN.js node_modules/echarts/lib/lang.js

@stereokai
Copy link

Thanks @dantimofte !

@Justineo
Copy link
Member

ECharts 5 now supports registerLocale at runtime. You can try to migrate to vue-echarts@6 for ECharts 5 support.

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

5 participants