fmt.Println( gettext( fmt.Sprintf("message text at %v with %v bytes", time.format( ), number) ) )fmt.Println( #gettext( "message text at %t with %n bytes", time, number ) )
or
fmt.Println( #gettext( msgid="jon001", time, number ))func #gettext( args Args ) {
src := "gettext(" // call real gettext function
current_positional_arg := 1
if args.msgid != nil { // keyword argument "msgid" not specified
src += args.msgid + " ,nil"
} else {
src += "nil, " + args.positional[1]
current_positional_arg := 2
}
for ; current_positional_arg <= args.positional.length; current_positional_arg {
arg = args.positional[current_positional_arg]
if reflect.TypeOf(arg) == "time.Time" {
src += ",gettext.TimeLocal(" + arg + ")"
} else if reflect.TypeOf(arg) == "int" {
src += ",gettext.Number(" + arg + ")"
} else {
src += "," + arg
}
}
compiler.AddStatement(*,src) // replaces the #gettext( ) with real code
}
#gettext(msgid="jon001", number, time)
would be replaced with
gettext("jon001", nil, gettext.Number(number), gettext.TimeLocal(time) )
#msg( language=en, prefix=jon ) // english messages jon###
// translator-comments
// extracted-comments
// reference…
// flag…
#msg(
id=001, // msg id jon001
msgstr[0]="message text at %t with %n bytes",
...
msgstr[N]="message text at %t with %n bytes"
)
// translator-comments
// extracted-comments
// reference…
// flag…
#msg(
id=002, // message id jon002
msgstr[0]="message text at %t with %n bytes",
...
msgstr[N]="message text at %t with %n bytes"
)
// translator-comments
// extracted-comments
// reference…
// flag…
#msg(
id=003, // message id jon003
msgstr[0]="message text at %t with %n bytes",
...
msgstr[N]="message text at %t with %n bytes"
)--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/2325901c-906e-4977-a989-5e0c00297052%40googlegroups.com.
If proposal https://github.com/golang/go/issues/37292 fails, everyone will lose out on a great opportunity.
This compiler called function replaces the #gettext( ... ) as follows:#gettext(msgid="jon001", number, time)
would be replaced with
gettext("jon001", nil, gettext.Number(number), gettext.TimeLocal(time) )
There are many examples where compile time flexibility is important. Consider the adverse effect of GO limitations has had on the very important GNU GETTEXT( ) - native language support (multi-lingual messages and localization):
--
Sorry, somehow I scrolled over the definition of func #gettext. So: this function emits literal source code text to be inserted into the compilation point.There are interesting semantic implications here: the args can't be evaluated at compile time (unless they are constant expressions), but need to be passed as strings representing the expression plus a type.
--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/5024a878-1392-4f1e-ac48-799f0cf5eee8%40googlegroups.com.
Have you read https://godoc.org/golang.org/x/text/message ?
It's not gettext, but a better - though not perfect - solution for this i18n problem.
--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/8f667430-75ed-44a5-8e54-c1fa36398e5e%40googlegroups.com.
Why do you say that?
~/src/golang.org/x/text/message [master*]$ go env GO111MODULE
on
~/src/golang.org/x/text/message [master*]$ go version
go version go1.14 linux/amd64
~/src/golang.org/x/text/message [master*]$ go test
PASS
ok golang.org/x/text/message 0.024s
On Wed, 2020-03-11 at 01:08 -0700, miha.v...@gmail.com wrote:
> AFAIK this doesn't work in recent go versions and even less if you
> are using modules.
>
> On Wednesday, March 11, 2020 at 6:39:36 AM UTC+1, Tamás Gulácsi
> wrote:
> > Hi Jon,
> > Have you read https://godoc.org/golang.org/x/text/message ?
> > It's not gettext, but a better - though not perfect - solution for
> > this i18n problem.
>
> --
> You received this message because you are subscribed to the Google
> Groups "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it,
> send an email to golan...@googlegroups.com.
Choose a compile time language. Possibly GO, Python, Java, NodeJS or??),which is a bad idea for a variety of reasons.constexpr in C++. This comment is from the proposal. Not one person has disagreed with "very powerful". If you disagree, please say why? How is this not far more powerful than GO GENERATE, pre-processors and macro's?
Why isn't a very powerful feature important to everyone? Shouldn't the compiler developers spend more than 5 minutes consideration on very powerful features before they dismiss them? Isn't this proposal worth a "like" just to consider if it's possible?
This proposal is failing because of fear that we will repeat the mistakes of the past. Great developer's will ask how a powerful feature can be made safe in their product instead of finding excuses not to consider it. "liking" a proposal doesn't mean it will be implemented. Instead, it tells developer's it's important to you and try to find a way to implement that feature.
Compile time is not affected if #xxx( xxx ) is not used in the code.
Does GO GENERATE or pre-processors save compile time by reading the source twice?
Are they able to produce results as a programmable GO?
> do not follow the simplicity and design goals of GoWhy is this impossible to be part of the requirements?>Choose a compile time language. Possibly GO, Python, Java, NodeJS or??),which is a bad idea for a variety of reasons.I'm not saying user's have a choice. I'm saying this is a decision to be made during requirements or design phase.> What this proposal describes is a language that is very different from Go.If the language chosen is GO, then it's not different. It could be a brand new minimal language that is similar to GO. This is a decision to be discussed.> It's even more unlikely that that language would be one as powerfulWhy would you want a powerful language at compile time. You're not reading files, using goroutines or most other functionality used at run time.> It looks like what you want is something likeconstexprin C++.Constexpr is useless for solving complex problems at compile time (e.g. gettext). It's amazing how a poorly designed feature get's abused because the language does not meet our needs.> the args can't be evaluated at compile timeAt compile time, everything is a constant. The compiler breaks down #xxx( yyy ) as constants into AST's. When #xxx is called, the AST's are made available to the function as ARGS.> I used make and awk programs that generate assembly code tuned> to the exact demands of command line make configuration. Then it builds in go, then runs.I want consistency for everyone, available with GO and easy to use. I'm sure this worked for you but compile time does not need to be complex. Simplicity is your friend.Thanks, Jon.
--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/CAByJhJn584h2AM_kRr8eZaGShfu-FjKxgBwCWpL-Cq11t79svQ%40mail.gmail.com.