Skip to content
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

C-format check doesn't allow positional values #6249

Open
2 tasks done
sethhillbrand opened this issue Jul 1, 2021 · 3 comments
Open
2 tasks done

C-format check doesn't allow positional values #6249

sethhillbrand opened this issue Jul 1, 2021 · 3 comments
Labels
enhancement Adding or requesting a new feature.

Comments

@sethhillbrand
Copy link

When the C-format check is enabled, positional arguments such as %1$s raise an error.

I already tried

To Reproduce the issue

Steps to reproduce the behavior:

  1. Go to 'https://hosted.weblate.org/translate/kicad/master-source/zh_Hans/?checksum=65ad27d657ff921f'
  2. Note that the source string uses default position format (%s)
  3. When translating to Chinese, the position of the arguments needs to change, so the positional format it used
  4. Note that this fails the c-format check

Expected behavior

We expect that default order variables can be replaced in translation with positional variables without error

Screenshots

image

Server configuration and status

Observed on Weblate hosted instance

@nijel
Copy link
Member

nijel commented Jul 1, 2021

The check currently looks for same format strings as in the source. While this is the correct approach in most cases, it is better to use position-based format in the source string as well to make sure it is really supported by the printf engine (there used to be implementations which did not support this).

@nijel nijel added the enhancement Adding or requesting a new feature. label Jul 1, 2021
@sethhillbrand
Copy link
Author

Thank you for looking into this.

Please note that even on systems where printf does not support this (and so it should not exist in the source string), libintl.a provides a replacement function that is activated for translations [1].

[1] https://www.gnu.org/software/gettext/manual/html_node/c_002dformat.html

@nijel
Copy link
Member

nijel commented Jul 1, 2021

I know it's possible to use libintl, but whether it is being used the translator typically does not know, that's why it's good to be explicit in the source string in this.

Still, Weblate probably should not complain on this, as most platforms these days will support it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Adding or requesting a new feature.
Projects
None yet
Development

No branches or pull requests

2 participants