Disambiguate identical alias strings (e.g. "a" for "app" and "add") #647
Closed
opened 2025-09-04 16:19:28 +00:00 by 3wordchant
·
13 comments
No Branch/Tag Specified
main
renovate/golang-1.27
local-integration-testing
renovate/github.com-charmbracelet-bubbletea-2.x
fix/492
renovate/github.com-charmbracelet-lipgloss-2.x
renovate/otel-weaver-0.x
renovate/codespell-2.x
renovate/tonistiigi-xx-1.x
renovate/alpine-3.x
renovate/github.com-charmbracelet-log-2.x
chore-deps
fix/deps
fix/613
0.13.0-beta
0.13.0-rc2-beta
0.13.0-rc1-beta
0.12.0-beta
0.11.0-beta
0.10.1-beta
0.10.0-beta
0.10.0-rc2-beta
0.10.0-rc1-beta
0.9.0-beta
0.8.1-beta
0.8.0-beta
0.8.0-rc2-beta
0.8.0-rc1-beta
0.7.0-beta
0.7.0-rc3-beta
0.7.0-rc2-beta
0.6.0-beta
0.5.1-beta
0.5.0-alpha
0.4.1-alpha
0.4.0-alpha
0.4.0-alpha-rc8
0.4.0-alpha-rc7
0.4.0-alpha-rc6
0.4.0-alpha-rc5
0.4.0-alpha-rc4
0.4.0-alpha-rc3
0.4.0-alpha-rc2
0.4.0-alpha-rc1
0.3.1-alpha-rc2
0.3.1-alpha-rc1
0.3.1-rc1
0.3.0-alpha
0.2.2-alpha
0.2.1-alpha
0.2.0-alpha
0.1.8-alpha
0.1.7-alpha
0.1.6-alpha
0.1.5-alpha
0.1.4-alpha
0.1.3-alpha
0.1.2-alpha
0.1.1-alpha
0.1.0-alpha
10.0.5
10.0.3
10.0.2
10.0.1
10.0.0
9.0.0
8.0.1
8.0.0
0.7.4
0.7.3
0.7.2
0.7.1
0.7.0
checkout
0.6.0
0.5.0
0.4.1
0.4.0
0.3.1
0.3.0
0.2.0
0.1.2
0.1.1
0.1.0
Labels
Clear labels
bug
build
ci/cd
critical fix
design
documentation
duplicate
easy-first-issue
enhancement
help wanted
i10n
i18n
installer
invalid
question
release
release-candidate
security
tech-debt
test
wontfix
Something is not working
go build related issues
Building things with CI/CD
https://docs.coopcloud.tech/federation/resolutions/passed/010/
UI/UX
Documenting all the things
This issue or pull request already exists
Something for new people to get stuck into. We hope it's easy!
New feature
Need some help
Everything to do with localisation
Everything to do with internationalisation
Everything to do with the install script.
Something is wrong
More information is needed
Release management
Related to the new release candidate
Security related
Unit/integration testing
This won't be fixed
No labels
i18n
Milestone
No items
No Milestone
Projects
Clear projects
No projects
Assignees
3wordchant
aadil (Aadil Ayub)
abra-bot (Abra Bot)
ammaratef45
amras (Sarma)
Apfelwurm
BornDeleuze
Brooke
carla
cas (Cassowary)
coopcloud
cyrnel
decentral1se (d1)
dede
devydave
fauno (fauno)
iexos
jade (Jade Ambrose)
jjsfunhouse
jmakdah2 (Jackie Makdah)
joe-irving (Joe Irving)
kawaiipunk (KawaiiPunk)
knoflook
kolaente
lambdabundesverband
linnealovespie (April)
moosemower
moritz
notplants
oxaliq (sorrel)
p4u1
pharaohgraphy (Andrew 🐦🔥❤️🔥✴️)
renovate-bot (Comrade Renovate Bot)
ripclap
simon
sixsmith (Sixsmith)
stevensting
trav (Trav Fryer)
val (val (he/him))
yksflip
Clear assignees
No Assignees
3wordchant
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: toolshed/abra#647
Reference in New Issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
For example, this string is showing up with 2 translation notes:
abra appaliases. use a comma separated list of aliases with no spaces in betweenabra server addaliases. use a comma separated list of aliases with no spaces in betweenSo, it's really just a coincidence that both strings are "a" in the English version; both should be translated separately.
It seems like the most gettext-y way to handle this is with "contexts" – in our case, using
GetCinstead ofGet.Ouch, could be wrong but I think
snapd'sxgettext-godoesn't support context at all? 🫠Not seeing it here: https://github.com/canonical/snapd/blob/master/i18n/xgettext-go/main.go
Hmmmmm, maybe we need to do like incus in https://github.com/lxc/incus/blob/092990416a5c2ffc056822e2d2ad62d7ad657204/internal/i18n/i18n_linux.go#L9-L12 and wrap our call:
In a function istead of a direct
varand do some finagling there? I think you could dostring...variable arguments in a function which takes 0 or more strings? There's no optional arguments in Go but you can do it by using what is called the "functional options" approach. I would hope this would be easy to sort... then we could do one of these two?https://golang.cafe/blog/golang-functional-options-pattern.html
Yep the function side makes sense, I had tried out this but indeed functional options is maybe cleaner:
The problem is that, although
xgettext-gowill pick up all thei18n.Ginvocations, it won't add the context; we should be seeing an extra line in the POT file.i.e. with the above, making this change:
Should produce this POT content:
But,
msgctxtdoesn't get added.@3wordchant thanks! That makes sense 🧗
Fuck me, we really have been backed into a wall on this one. It's not our fault ofc and is due to the Go ecosystem being so shaky on translation support. I have a work-around which is not actually the worst thing ever but it's pretty damn bad. It's a migration back to
xgotext(😱)We would need to chaos fork it (😱) and override https://github.com/leonelquinteros/gotext/blob/270f280ba5443979a5ddfc6010d874f19b558d1b/cli/xgotext/parser/pkg-tree/golang.go#L88-L90 (i'm guessing) to match
coopcloud.tech/abra/pkg/gotextand then define aGet/GetCfunction there (therefore hacking thegotext.Get/GetCmatching but being our version ofGet/GetCand not the upstream (😱). We need to do this because we need to initialise the locale once and read the translations from the embedded filesystem and have a central import from there. Then we justsed -iall uses ifi18nin the import URLs and function calls...You could theoretically hack the matching on the function name but I tried to dive into this and ran into an inscrutable list of integers for which there is no explanation for yet https://github.com/leonelquinteros/gotext/issues/124#issuecomment-3211589971 (😱)
I noticed that the
-pkg-treeoption (instead of-in) onxgotextis much faster so it might not be such a massive slow down for our automation. It is however a noticeably slow down however compared to the zippyxgettext-go...I could take a run at the migration but this seems like a pretty drastic / nuclear option... especially the need to re-work our CI automation also once more...
Wow full-on magical software numerology incantation 😅
Oh very nice 👏
I don't mind doing that part.
Obviously forking does seem pretty last-resort, but I'm not sure what else we do? The only alternative I can think of would be to establish our own (cursed) convention of e.g.
u#upgradein the string, then we strip#and everything after it? Basically rebuilding gettext contexts ourselves.@3wordchant hahaha
u#uppgradethat would be spectacularly cursed 😂 love it. OK and I guess option 3 is really diving intoxgettext-goand trying to patch it also to make it work. Bearing in mind we're running an ancient verison of the software also. I feel like getting back onxgotextis maybe more future-proof as it is the "new kid on the block" but at the same time, the maintainer hasn't replied to my issue and i don't see much activity... so pros/cons everywhere... any preferences? will hopefully have time to dive into this next week unless you take a run at it!OK, I couldn't resist and have managed to get a working prototype with
xgotextand managed to test / patchabraand see themsgctxtturn up! I've submitted a PR. If they don't accept it, we can fork but hopefully we can get this merged upstream. If we want to go in this direction, I can clean it all up and temporarily fork so we can make progress...Incredible 🤩
Decision from Monday: we play the waiting game, hope that
leonelquinterosmerges the PR by the time we need to launch, decide between various unsavoury forking options if not.Wait I'm confused, this was our plan for #629 - does it apply here too?
I think for this we do need a temporary fork to make progress and have those translations put in place for testing? Sorry, I think I wasn't that clear... I can arrange this and it's not much work. No reason to hold up the new release of
abranow, I'd say. This can be punted into "abra next next" as we improve the translation situation...Fuck me,
xgotextdoesn't support comments 😱 I'm going back to a final wildcard attempt to just forkxgettext-goand add context support somehow. I think it might be the best way forward and maybe we'll need to add more stuff also in the future... will be poking at this in the coming days...OK, I think I've got a lead on a fix: #672
I've just realised that the latest
gettextactually supports Go natively 😱 It's not really conveniently available in most distros, so maybe we can hold off on that for now and migrate to it in a few months. Then things should be much simpler. I did compile it from source but it was pretty gnarly, so I'm not sure if worth the effort to docker-ize it right now. Feel free to take a run at it if you want! I assume it supports everything we need as it is the OG upstream.Serious yak shaving going down here!