-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
[BUG] When using docker to build an image, resources (eg: i18n) cannot be included #2874
Comments
的确目前的代码没有包含这个目录,可以试试这几个方法,各方法无关联。
|
It is true that the current code does not include this directory, you can try these methods, each method is irrelevant.
|
最新结果,将多语言文件放到目录manifest/i18n下面 |
For the latest results, put the multilingual files under the directory manifest/i18n |
编译后目录结构参考: /app/bin/app 直接读取是没法读取的,使用 这应该是在文档中有所提示,我觉得这个坑应该会有不少人遇到
|
Directory structure reference after compilation: /app/bin/app cannot be read directly. The path printed by This should be hinted in the documentation, I think this pit will be encountered by many people
|
你的情况是资源文件在二进制外且不是同目录下,这种情况只能自己确定好路径然后配置即可。 可以试试将资源文件打包到二进制中,就不用指定了,简单很多。 |
In your case, the resource file is outside the binary and not in the same directory. In this case, you can only determine the path and configure it yourself. You can try to package the resource files into the binary, so you don’t need to specify it, it’s much simpler. |
默认的gi18n.Manager有bug,使用gi18n.XXX无法读取到gres中的资源。 如果是使用gres打包的资源文件可以暂时使用如下方法 myi18n := gi18n.New(gi18n.Options{
Path: "manifest/i18n",// 指定你在gres中的资源目录
})
myi18n.SetLanguage("zh-CN")
fmt.Println(myi18n.Translate(context.Background(), "{#hello}{#world}")) |
The default gi18n.Manager has a bug, and resources in gres cannot be read using gi18n.XXX. |
我已经设置了,没用的,读不到 |
@shuqingzai @hailaz 这个i18n的目录不建议手动设置而是使用默认的,当使用docker打包的时候,请将i18n的目录使用Dockerfile拷贝到二进制的同目录下即可使用。 例如: @hailaz 说的资源管理不支持i18n是另一个问题了。 |
fix in #2961 @shuqingzai |
1. What version of
Go
and system type/arch are you using?#-> % go version go version go1.21.0 darwin/amd64
2. What version of
GoFrame
are you using?3. Can this issue be re-produced with the latest release?
是的
4. What did you do?
在使用 docker 编译的时候,需要怎么样才能包含 i18n 资源???
编译配置
Dockerfile
使用下面的 Dockerfile 进行编译运行
构建命令
运行后镜像后, 没有包含
resource
下i18n
资源文件,编译过程也看到类似如下日志编译命令主要是
make build
,使用的是 gf 内置的 Makefile ,但是无法加载资源我不确定是否与
gf/i18n/gi18n/gi18n_manager.go
Line 49 in e0e0043
resource
中, 而且我的编译配置当中也已经包含了resource
目录( packSrc: "resource" )5. What did you expect to see?
希望可以给出指导,正常在 docker 镜像中把资源编译成二进制文件
6. What did you see instead?
The text was updated successfully, but these errors were encountered: