snap pt_BR locale shows warning every time

Bug #1932579 reported by Junior Martins
60
This bug affects 10 people
Affects Status Importance Assigned to Milestone
snapd
Fix Committed
Medium
Unassigned
language-pack-pt-base (Ubuntu)
Confirmed
Undecided
Unassigned
snapd (Ubuntu)
Fix Committed
Medium
Miguel Pires

Bug Description

The following warning appears every time I type a snap command, and thus breaks auto-completion.

2021/06/18 13:15:24.372374 main.go:176: description of prepare-image's "<target-dir>" is lowercase in locale "pt_BR": "o directório de destino"

The problem seems locale dependent, since "LANG=C snap" doesn't show this warning. I'm currently using Ubuntu 21.04, and this bug happens since I upgraded from 20.10. (I don't know if this is off-topic or where I can help, but "directório" is more pt_PT than pt_BR, which could be "pasta/diretório")

echo $LANG output:
pt_BR.UTF-8

lsb_release -rb output:
Description: Ubuntu 21.04
Release: 21.04

apt-cache policy snapd output:
snapd:
  Instalado: 2.49.2+21.04ubuntu1
  Candidato: 2.49.2+21.04ubuntu1
  Tabela de versão:
 *** 2.49.2+21.04ubuntu1 500
        500 http://br.archive.ubuntu.com/ubuntu hirsute/main amd64 Packages
        100 /var/lib/dpkg/status

snap list output:
...[other packages]...
snap-store 3.38.0-64-g23c4c77 547 latest/stable canonical✓ -
snapd 2.51 12159 latest/stable canonical✓ snapd

Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in snapd (Ubuntu):
status: New → Confirmed
Revision history for this message
Erick Augusto Meira Silva (eams1234) wrote :

It also affects Ubuntu 20.04 LTS after a recent update.

Revision history for this message
Carlos Eduardo Alves (kmiksi) wrote (last edit ):

This bug also prevents the use of snap command autocomplete, echoing these error messages when TAB is pressed....

```
$ snap [TAB]2021/08/26 11:39:40.041113 main.go:176: description of prepare-image's "<target-dir>" is lowercase in locale "pt_BR": "o directório de destino"

```

I found that there is a typo in the file "/usr/share/locale-langpack/pt/LC_MESSAGES/snappy.mo".

```
$ dpkg -S /usr/share/locale-langpack/pt/LC_MESSAGES/snappy.mo
language-pack-pt-base: /usr/share/locale-langpack/pt/LC_MESSAGES/snappy.mo
$ dpkg -l language-pack-pt-base
ii language-pack-pt-base 1:20.04+20210802 all translations for language Portuguese
```

An available workaround is to fix the file manually...

```
sudo sed -i 's/o directório de destino/O directório de destino/' /usr/share/locale-langpack/pt/LC_MESSAGES/snappy.mo
```

Probably must be fixed into language-pack-pt-base translation sources.

Or.... this can be interpreted as a bug in snapd that imposes capitalization rules on translations, at some "main.go" at line 176, as the message says.
I've downloaded snapd sources and found this validation on "cmd/snap/main.go":

```
$ dpkg -l snapd
ii snapd 2.49.2+20.04 amd64 Daemon and tooling that enable snap packages
$ cd /tmp && apt source snapd
$ sed '174,177!d' /tmp/snapd-2.49.2+20.04/cmd/snap/main.go
                // note IsLower != !IsUpper for runes with no upper/lower.
                if unicode.IsLower(r) && !strings.HasPrefix(desc, "login.ubuntu.com") && !strings.HasPrefix(desc, cmdName) {
                        noticef("description of %s's %q is lowercase: %q", cmdName, optName, desc)
                }
```

Changed in language-pack-pt-base (Ubuntu):
status: New → Confirmed
Revision history for this message
Flavio Schurt (fschurt) wrote (last edit ):

$ sudo apt install libgtk3-nocsd0

May be a workround..... Works for me!
on Ubuntu 20.04.3

Regards

Revision history for this message
Fábio Blanco (iogui) wrote :
Download full text (5.0 KiB)

I've made a fresh install with Ubuntu 20.04.3 and I'm facing this problem too.
But I think the workaround proposed by Carlos would be a little bit harsh to put in practice since I don't now how many instances of translation are triggering this same error.
Every time I run a snap command, and not just on auto-completion, I receive lots of error messages.
See:

$ snap --help
2021/09/16 19:38:47.210141 main.go:176: description of advise-snap's "format" is lowercase in locale "pt_BR": "sar o formato de saída indicado\x00"
2021/09/16 19:38:47.210302 main.go:176: description of create-user's "known" is lowercase in locale "pt_BR": "se as asserções conhecidas para a criação de utilizador\x00"
2021/09/16 19:38:47.210368 main.go:176: description of download's "channel" is lowercase in locale "pt_BR": "sar este canal em vez do 'stable'\x00"
2021/09/16 19:38:47.210381 main.go:176: description of download's "basename" is lowercase in locale "pt_BR": "se este nome de base para os ficheiros snap e assertion (o padrão é <snap> _ <revision>)\x00"
2021/09/16 19:38:47.210419 main.go:176: description of find's "color" is lowercase in locale "pt_BR": "se um pouco de cor para destacar algumas coisas.\x00"
2021/09/16 19:38:47.210430 main.go:176: description of find's "unicode" is lowercase in locale "pt_BR": "se um pouco de Unicode para melhorar a legibilidade.\x00"
2021/09/16 19:38:47.210499 main.go:176: description of info's "color" is lowercase in locale "pt_BR": "se um pouco de cor para destacar algumas coisas.\x00"
2021/09/16 19:38:47.210511 main.go:176: description of info's "unicode" is lowercase in locale "pt_BR": "se um pouco de Unicode para melhorar a legibilidade.\x00"
2021/09/16 19:38:47.210573 main.go:176: description of list's "color" is lowercase in locale "pt_BR": "se um pouco de cor para destacar algumas coisas.\x00"
2021/09/16 19:38:47.210584 main.go:176: description of list's "unicode" is lowercase in locale "pt_BR": "se um pouco de Unicode para melhorar a legibilidade.\x00"
2021/09/16 19:38:47.210630 main.go:176: description of model's "color" is lowercase in locale "pt_BR": "se um pouco de cor para destacar algumas coisas.\x00"
2021/09/16 19:38:47.210641 main.go:176: description of model's "unicode" is lowercase in locale "pt_BR": "se um pouco de Unicode para melhorar a legibilidade.\x00"
2021/09/16 19:38:47.210666 main.go:176: description of pack's "check-skeleton" is lowercase in locale "pt_BR": "alidar metadados snap-dir apenas\x00"
2021/09/16 19:38:47.210751 main.go:176: description of recovery's "color" is lowercase in locale "pt_BR": "se um pouco de cor para destacar algumas coisas.\x00"
2021/09/16 19:38:47.210763 main.go:176: description of recovery's "unicode" is lowercase in locale "pt_BR": "se um pouco de Unicode para melhorar a legibilidade.\x00"
2021/09/16 19:38:47.210836 main.go:176: description of run's "r" is lowercase in locale "pt_BR": "sar uma revisão de snap específica quando executa um hook\x00"
2021/09/16 19:38:47.210862 main.go:176: description of logs's "f" is lowercase in locale "pt_BR": "spere por novas linhas e imprima-as assim que chegarem.\x00"
2021/09/16 19:38:47.211023 main.go:176: description of install's "color...

Read more...

Revision history for this message
Junior Martins (jrom) wrote (last edit ):

What is your output of "apt-cache policy snapd" and what version of snapd is shown by "snap list"?

I checked their GitHub page, and at <https://github.com/snapcore/snapd/blob/master/cmd/snap/main.go#L173> the description is different from comment #4 since it also includes "in locale "pt_BR"", which itself was changed fairly recently on May 18, 2021 with the commit <https://github.com/snapcore/snapd/commit/d6002db1fbf048baeac4c2e55c2d939579709249#diff-3e3ed6fb2507f825b010f93a1e81f1610fca76413b0eb9588f8c23e7095cf0a2>

The conditional expression itself didn't change though, so I think the bug itself should be before that or was created after it in the translation sources (I don't know how/where to check them though, any help is greatly appreciated)

Revision history for this message
Fábio Blanco (iogui) wrote :

@kmiksi, actually, I think that your proposed workaround enhanced the problem. The error messages from my previous post started to show up after I've run the sed command you've proposed and I think this happened because the file `snappy.mo` is a binary not an ascii text file. I have reverted my changes by running:

```
sudo apt --reinstall install language-pack-pt-base
```

And now I have only the original error message:

```
$ snap --help
2021/09/16 21:43:52.882927 main.go:176: description of prepare-image's "<target-dir>" is lowercase in locale "pt_BR": "o directório de destino"
O comando snap permite instalar, configurar, atualizar e remover snaps.
...

```

Revision history for this message
Fábio Blanco (iogui) wrote :

@jrom, @kmiksi may be using Ubuntu 20.04 like me because his version of snapd in apt package is the same as mine:

```
$ apt policy snapd
snapd:
  Instalado: 2.49.2+20.04
  Candidato: 2.49.2+20.04
  Tabela de versão:
 *** 2.49.2+20.04 500
        500 http://br.archive.ubuntu.com/ubuntu focal-updates/main amd64 Packages
        100 /var/lib/dpkg/status
     2.48.3+20.04 500
        500 http://security.ubuntu.com/ubuntu focal-security/main amd64 Packages
     2.44.3+20.04 500
        500 http://br.archive.ubuntu.com/ubuntu focal/main amd64 Packages
```

```
$ snap list | grep snapd
2021/09/16 22:07:53.899186 main.go:176: description of prepare-image's "<target-dir>" is lowercase in locale "pt_BR": "o directório de destino"
snapd 2.51.4 12883 latest/stable canonical* snapd

```

Revision history for this message
Fábio Blanco (iogui) wrote (last edit ):

@jrom, the condition didn't changed. This commit you pointed was released in snapd version 2.51
You can see it here:
https://github.com/snapcore/snapd/compare/2.50.1...2.51

If you compare the release 2.51 with the latest release 2.52:
https://github.com/snapcore/snapd/compare/2.51...2.52

...you will see that there is no significant change in this `cmd/snap/main.go` file. They just changed some lines positions but the content is the same.

The fact that the locale "pt_BR" is not on the code, means nothing since this is replaced in runtime in the variable "%q".

The bug may be in the translation in the `language-pack-pt-base` package itself.

Revision history for this message
Maciej Borzecki (maciek-borzecki) wrote :

We also have a change in snapd source code that will no longer show these messages: https://github.com/snapcore/snapd/pull/10756

Revision history for this message
Carlos Eduardo Alves (kmiksi) wrote :

@iogui, every system I've tried works well with that workaround (4 installations with Ubuntu 20.04). Please reinstall language-pack-pt-base an try again.

Yes, it is a binary file, a gettext .po compiled into a .mo. The sed is a quick workaround that works fine for me even with the binary. If you continue having problems, another way is retranslating with these commands:
```
sudo cp /usr/share/locale-langpack/pt/LC_MESSAGES/snappy.mo /usr/share/locale-langpack/pt/LC_MESSAGES/snappy.mo~
msgunfmt /usr/share/locale-langpack/pt/LC_MESSAGES/snappy.mo > /tmp/snappy.po
sed -i 's/o directório de destino/O directório de destino/' /tmp/snappy.po # or edit with PoEditor
sudo msgfmt /tmp/snappy.po -o /usr/share/locale-langpack/pt/LC_MESSAGES/snappy.mo
```

I can't find the origin of these translations to contribute to language-pack-pt-base.
Do you know about these translations and how to contribute?
I only find some git hooks in the sources manipulating translation contents, but don't understood clearly how it is done. Some help is welcome.

Revision history for this message
Ian Johnson (anonymouse67) wrote :

The message should no longer be shown anymore in snapd as the PR referenced by Maciej has been merged and should be available on the edge channel of snapd in the few hours. Please give it a try if you like with:

```
snap install snapd --edge || snap refresh snapd --edge

# test the snap command to make sure the message no longer appears

snap refresh snapd --stable
# to go back to tracking stable, as edge sometimes can have unstable changes on it
```

Thanks,
Ian

Changed in snapd (Ubuntu):
status: Confirmed → Fix Committed
importance: Undecided → Medium
Changed in snapd:
milestone: none → 2.53
status: New → Fix Committed
importance: Undecided → Medium
Revision history for this message
Fábio Blanco (iogui) wrote (last edit ):

@maciek-borzecki, good work!! It seems like a good solution!

@kmiksi, I was searching for it too. I don't know how the translations are in fact included in the sources but I've found how we can contribute to the translation, see those links:

https://launchpad.net/~ubuntu-l10n-pt-br

https://answers.launchpad.net/launchpad/+question/45811

https://launchpad.net/~lp-l10n-pt-br

<email address hidden>

https://lists.ubuntu.com/mailman/listinfo/ubuntu-l10n-ptbr

https://wiki.ubuntu.com/pt_BR/TimeDeTraducao

@anonymouse67, I've tried the commands you've provided but it didn't work. See:

```
$ sudo snap install snapd --edge || sudo snap refresh snapd --edge
[sudo] senha para my-user:
2021/09/18 12:54:59.334587 main.go:176: description of prepare-image's "<target-dir>" is lowercase in locale "pt_BR": "o directório de destino"
snap "snapd" já está instalado, consulte 'snap help refresh'
```

Revision history for this message
Ian Johnson (anonymouse67) wrote :

@iogui could you try again? snapd on the edge channel may not have finished building by the time you tried, but I see that there was an update pushed out this morning.

Revision history for this message
Fábio Blanco (iogui) wrote :

@anonymouse67, tested just now and the result is the same. I don't know much about snap commands but maybe the parameter "--edge" is not working as you expect it to... shouldn't the command be with a parameter "--channel=latest/edge" to select the channel?... Because I don't know, I've not tried something different as I'm afraid to mess with my system.

Revision history for this message
Ian Johnson (anonymouse67) wrote :

@iogui, hmm it could be that our fix isn't working, can you show the output of these commands:

snap version
snap list

Revision history for this message
Miguel Pires (miguelpires1) wrote (last edit ):

Hi (or Olá for the PT crowd). I think snapd just wasn't refreshed, @iogui's output doesn't show it:

```
$ sudo snap install snapd --edge || sudo snap refresh snapd --edge
[sudo] senha para my-user:
2021/09/18 12:54:59.334587 main.go:176: description of prepare-image's "<target-dir>" is lowercase in locale "pt_BR": "o directório de destino"
snap "snapd" já está instalado, consulte 'snap help refresh'
```

`snap install <snap>` (when run on an already installed snap) returns 0. So the right-side of the `||` didn't run and snapd wasn't refreshed to edge.

@iogui, can you run `sudo snap refresh snapd --edge` and let us know if `snap list` logs the warning? I've just tested with edge and the fix seems to be working. If you still see the warning, then could you please run `snap version` and post the output? Thanks for your help

Revision history for this message
Ian Johnson (anonymouse67) wrote :

Ah Miguel, thanks for realizing my error, I should have probably just said something like

sudo snap install snapd --edge; sudo snap refresh snapd --edge

which will ensure that it's always installed and gets refreshed.

Revision history for this message
Fábio Blanco (iogui) wrote :

@anonymouse67 and @miguelpires1, sorry for the delay, I was not at the office today.

@miguelpires1, you're right a simple `sudo snap refresh snapd --edge` did it.

@anonymouse67, the correction seems to work:

```
$ snap version
snap 2.52+git869.g363f829
snapd 2.52+git869.g363f829
series 16
ubuntu 20.04
kernel 5.11.0-34-generic

$ snap list
Nome Versão Rev A seguir Editor Notas
core 16-2.51.4 11606 latest/stable canonical✓ core
core18 20210722 2128 latest/stable canonical✓ base
core20 20210702 1081 latest/stable canonical✓ base
gnome-3-28-1804 3.28.0-19-g98f9e67.98f9e67 161 latest/stable canonical✓ -
gnome-3-34-1804 0+git.3556cb3 72 latest/stable/… canonical✓ -
gtk-common-themes 0.1-52-gb92ac40 1515 latest/stable/… canonical✓ -
intellij-idea-ultimate 2021.2.2 319 latest/stable jetbrains✓ classic
skype 8.75.0.140 183 latest/stable skype✓ -
snap-store 3.38.0-64-g23c4c77 547 latest/stable/… canonical✓ -
snapd 2.52+git869.g363f829 13449 latest/edge canonical✓ snapd
telegram-desktop 3.1.0 3119 latest/stable telegram.desktop -

$ snap --help
O comando snap permite instalar, configurar, atualizar e remover snaps.
Os Snaps são pacotes que funcionam em muitas distribuições Linux diferentes,
permitindo a entrega e operação seguras das aplicações e utilitários mais recentes.

Uso: snap <command> [<options>...]
...

```

Changed in snapd (Ubuntu):
assignee: nobody → Miguel Pires (miguelpires1)
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.