Coder Social home page Coder Social logo

gettext's People

Contributors

mvo5 avatar sqp avatar xiam avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

gettext's Issues

Panic: interface conversion: ast.Expr is *ast.SelectorExpr, not *ast.Ident

The following code causes a panic:

package x

func fn() {
	c.client.Get()
}
go-xgettext -o "./pkg/locales/default.pot" --keyword=gotext.Get pkg/file.go
panic: interface conversion: ast.Expr is *ast.SelectorExpr, not *ast.Ident

goroutine 1 [running]:
main.inspectNodeForTranslations(0xc000050100, 0xc000072100, 0x56c0c0, 0xc000050140, 0x8)
	/home/presslabs/go/src/github.com/gosexy/gettext/go-xgettext/main.go:163 +0xafd
main.processSingleGoSource.func1(0x56c0c0, 0xc000050140, 0xc00000a540)
	/home/presslabs/go/src/github.com/gosexy/gettext/go-xgettext/main.go:236 +0x47
go/ast.inspector.Visit(0xc00000a240, 0x56c0c0, 0xc000050140, 0x10, 0x54b084)
	/usr/local/go/src/go/ast/walk.go:373 +0x3a
go/ast.Walk(0x56bd80, 0xc00000a240, 0x56c0c0, 0xc000050140)
	/usr/local/go/src/go/ast/walk.go:52 +0x66
go/ast.Walk(0x56bd80, 0xc00000a240, 0x56c380, 0xc0000465b0)
	/usr/local/go/src/go/ast/walk.go:196 +0x1b12
go/ast.walkStmtList(0x56bd80, 0xc00000a240, 0xc0000465c0, 0x1, 0x1)
	/usr/local/go/src/go/ast/walk.go:32 +0x9e
go/ast.Walk(0x56bd80, 0xc00000a240, 0x56c040, 0xc0000605d0)
	/usr/local/go/src/go/ast/walk.go:224 +0x1b67
go/ast.Walk(0x56bd80, 0xc00000a240, 0x56c4c0, 0xc000060600)
	/usr/local/go/src/go/ast/walk.go:344 +0xd6d
go/ast.walkDeclList(0x56bd80, 0xc00000a240, 0xc0000465d0, 0x1, 0x1)
	/usr/local/go/src/go/ast/walk.go:38 +0x9e
go/ast.Walk(0x56bd80, 0xc00000a240, 0x56c440, 0xc000072100)
	/usr/local/go/src/go/ast/walk.go:353 +0x2656
go/ast.Inspect(0x56c440, 0xc000072100, 0xc00000a240)
	/usr/local/go/src/go/ast/walk.go:385 +0x4b
main.processSingleGoSource(0xc000050100, 0x7fffd2dc037f, 0x28, 0xc00000e140, 0x2)
	/home/presslabs/go/src/github.com/gosexy/gettext/go-xgettext/main.go:235 +0x14e
main.processFiles(0xc00000e150, 0x1, 0x4, 0x5, 0x5)
	/home/presslabs/go/src/github.com/gosexy/gettext/go-xgettext/main.go:215 +0xa8
main.main()
	/home/presslabs/go/src/github.com/gosexy/gettext/go-xgettext/main.go:344 +0x138

But the following code doesn't cause the panic:

package x

func fn() {
	c.client.Update()
}

[whishlist] provide xgettext to extract `` strings

Hi,

I use gosexy in one of my projects and I'm quite happy. One issue I noticed is that xgettext does not extract `` style strings. I created a custom go xgettext for this that uses the golang/ast module and that seems to make the extraction very simple. If thats something you are interessted in I can create a branch and send you a pull request, my current proof-of-concept is at http://bazaar.launchpad.net/~mvo/snappy/snapy-out-own-xgettext/view/head:/i18n/xgettext-go/main.go (but the real version would look a lot nicer :)

Cheers,
Michael

Panic: runtime error: index out of range

The following code causes a panic:

package x

func fn() {
	Get()
}
go-xgettext -o "./pkg/locales/default.pot" --keyword=gotext.Get pkg/apiserver/controller/site/env_var.go
panic: runtime error: index out of range

goroutine 1 [running]:
main.inspectNodeForTranslations(0xc000050100, 0xc000072100, 0x56c0c0, 0xc000050140, 0x8)
	/home/presslabs/go/src/github.com/gosexy/gettext/go-xgettext/main.go:155 +0xb7b
main.processSingleGoSource.func1(0x56c0c0, 0xc000050140, 0xc00000a4a0)
	/home/presslabs/go/src/github.com/gosexy/gettext/go-xgettext/main.go:236 +0x47
go/ast.inspector.Visit(0xc00000a1a0, 0x56c0c0, 0xc000050140, 0x10, 0x54b084)
	/usr/local/go/src/go/ast/walk.go:373 +0x3a
go/ast.Walk(0x56bd80, 0xc00000a1a0, 0x56c0c0, 0xc000050140)
	/usr/local/go/src/go/ast/walk.go:52 +0x66
go/ast.Walk(0x56bd80, 0xc00000a1a0, 0x56c380, 0xc000046590)
	/usr/local/go/src/go/ast/walk.go:196 +0x1b12
go/ast.walkStmtList(0x56bd80, 0xc00000a1a0, 0xc0000465a0, 0x1, 0x1)
	/usr/local/go/src/go/ast/walk.go:32 +0x9e
go/ast.Walk(0x56bd80, 0xc00000a1a0, 0x56c040, 0xc0000605d0)
	/usr/local/go/src/go/ast/walk.go:224 +0x1b67
go/ast.Walk(0x56bd80, 0xc00000a1a0, 0x56c4c0, 0xc000060600)
	/usr/local/go/src/go/ast/walk.go:344 +0xd6d
go/ast.walkDeclList(0x56bd80, 0xc00000a1a0, 0xc0000465b0, 0x1, 0x1)
	/usr/local/go/src/go/ast/walk.go:38 +0x9e
go/ast.Walk(0x56bd80, 0xc00000a1a0, 0x56c440, 0xc000072100)
	/usr/local/go/src/go/ast/walk.go:353 +0x2656
go/ast.Inspect(0x56c440, 0xc000072100, 0xc00000a1a0)
	/usr/local/go/src/go/ast/walk.go:385 +0x4b
main.processSingleGoSource(0xc000050100, 0x7fffabd2737f, 0x28, 0xc00000e140, 0x2)
	/home/presslabs/go/src/github.com/gosexy/gettext/go-xgettext/main.go:235 +0x14e
main.processFiles(0xc00000e150, 0x1, 0x4, 0x5, 0x5)
	/home/presslabs/go/src/github.com/gosexy/gettext/go-xgettext/main.go:215 +0xa8
main.main()
	/home/presslabs/go/src/github.com/gosexy/gettext/go-xgettext/main.go:344 +0x138

And the following code doesn't cause panic:

package x

func fn() {
	OtherFunc()
	get()
}

Travis jobs failing on Intel

Hi All,
I am running jobs on travis-ci and found that jobs are failing for go1.11.X and 1.12.X. Below are the logs

$ git clone --depth=50 --branch=master https://github.com/kishorkunal-raj/gettext.git kishorkunal-raj/gettext
$ travis_export_go 1.11.x github.com/kishorkunal-raj/gettext
0.01s0.08s$ travis_setup_go
go version go1.11.13 linux/amd64
$ export GOPATH="/home/travis/gopath"
$ export PATH="/home/travis/gopath/bin:/home/travis/.gimme/versions/go1.11.13.linux.amd64/bin:/home/travis/bin:/home/travis/bin:/home/travis/.local/bin:/usr/local/lib/jvm/openjdk11/bin:/opt/pyenv/shims:/home/travis/.phpenv/shims:/home/travis/perl5/perlbrew/bin:/home/travis/.nvm/versions/node/v8.12.0/bin:/home/travis/.rvm/gems/ruby-2.5.3/bin:/home/travis/.rvm/gems/ruby-2.5.3@global/bin:/home/travis/.rvm/rubies/ruby-2.5.3/bin:/home/travis/gopath/bin:/home/travis/.gimme/versions/go1.11.1.linux.amd64/bin:/usr/local/maven-3.6.3/bin:/usr/local/cmake-3.12.4/bin:/usr/local/clang-7.0.0/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin:/home/travis/.rvm/bin:/home/travis/.phpenv/bin:/opt/pyenv/bin:/home/travis/.yarn/bin"
$ export GO111MODULE="auto"
$ gimme version
v1.5.4
$ go version
go version go1.11.13 linux/amd64
go.env
$ go env
install
13.36s$ go get -t -v ./...
6.36s$ go test -v ./...

github.com/stretchr/testify/assert

../../stretchr/testify/assert/assertions.go:1703:5: undefined: errors.Is
../../stretchr/testify/assert/assertions.go:1726:6: undefined: errors.Is
../../stretchr/testify/assert/assertions.go:1749:5: undefined: errors.As
../../stretchr/testify/assert/assertions.go:1766:7: undefined: errors.Unwrap
../../stretchr/testify/assert/assertions.go:1770:7: undefined: errors.Unwrap
FAIL github.com/kishorkunal-raj/gettext [build failed]
=== RUN Test
OK: 16 passed
--- PASS: Test (0.00s)
PASS
ok github.com/kishorkunal-raj/gettext/go-xgettext 0.006s
The command "go test -v ./..." exited with 2.

Done. Your build exited with 1.

Please help me out to fix it.

How to set locale per goroutine?

I want to use this in a web app, where potentially every request comes in for a different locale.

The SetLocale() command seems to be global.

How do you handle this in case where an app is serving in multiple languages similtaneously, different locale per goroutine?

If this functionality already exists, please document how.

Thank you

Fails to Build: `undefined reference to `libintl_bind_textdomain_codeset'`

Environment

  • Alpine Linux 3.2.0 RC2
  • musl-1.1.8 (libc)
  • gettext-0.19.4 (gnu)
  • go-1.4.2
  • gettext commit 98b7b91

Error

After running make or trying to just run go get github.com/lxc/lxd . The gettext errors are produced as shown below.

go build
# _/home/admin/src/port2port/lxc/gettext
/tmp/go-build148138563/_/home/admin/src/port2port/lxc/gettext/_obj/gettext.cgo2.o: In function `_cgo_b28bc486a664_Cfunc_bind_textdomain_codeset':
./gettext.go:64: undefined reference to `libintl_bind_textdomain_codeset'
/tmp/go-build148138563/_/home/admin/src/port2port/lxc/gettext/_obj/gettext.cgo2.o: In function `_cgo_b28bc486a664_Cfunc_bindtextdomain':
./gettext.go:78: undefined reference to `libintl_bindtextdomain'
/tmp/go-build148138563/_/home/admin/src/port2port/lxc/gettext/_obj/gettext.cgo2.o: In function `_cgo_b28bc486a664_Cfunc_dcgettext':
./gettext.go:94: undefined reference to `libintl_dcgettext'
/tmp/go-build148138563/_/home/admin/src/port2port/lxc/gettext/_obj/gettext.cgo2.o: In function `_cgo_b28bc486a664_Cfunc_dcngettext':
./gettext.go:112: undefined reference to `libintl_dcngettext'
/tmp/go-build148138563/_/home/admin/src/port2port/lxc/gettext/_obj/gettext.cgo2.o: In function `_cgo_b28bc486a664_Cfunc_dgettext':
./gettext.go:126: undefined reference to `libintl_dgettext'
/tmp/go-build148138563/_/home/admin/src/port2port/lxc/gettext/_obj/gettext.cgo2.o: In function `_cgo_b28bc486a664_Cfunc_dngettext':
./gettext.go:142: undefined reference to `libintl_dngettext'
/tmp/go-build148138563/_/home/admin/src/port2port/lxc/gettext/_obj/gettext.cgo2.o: In function `_cgo_b28bc486a664_Cfunc_gettext':
./gettext.go:164: undefined reference to `libintl_gettext'
/tmp/go-build148138563/_/home/admin/src/port2port/lxc/gettext/_obj/gettext.cgo2.o: In function `_cgo_b28bc486a664_Cfunc_ngettext':
./gettext.go:179: undefined reference to `libintl_ngettext'
/tmp/go-build148138563/_/home/admin/src/port2port/lxc/gettext/_obj/gettext.cgo2.o: In function `_cgo_b28bc486a664_Cfunc_textdomain':
./gettext.go:207: undefined reference to `libintl_textdomain'
collect2: error: ld returned 1 exit status

Fix

Tell cgo to link libintl by changing line 26 of gettext.go from /* to

// #cgo LDFLAGS: -lintl

and then insert /* into line 27 of the same file.

Go Test

go build
go test
¡Hola mundo!
Una manzana
3 manzanas
Buenos días
¡Hasta luego!
Hallo, Welt!
Ein Apfel
3 Äpfel
Guten morgen
Aufwiedersehen!
PASS
ok      _/home/admin/src/port2port/lxc/gettext  0.002s

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.