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

No error on conflicting plural messages #400

Closed
kevinschweikert opened this issue Nov 12, 2024 · 3 comments · Fixed by #401
Closed

No error on conflicting plural messages #400

kevinschweikert opened this issue Nov 12, 2024 · 3 comments · Fixed by #401
Assignees
Labels

Comments

@kevinschweikert
Copy link

kevinschweikert commented Nov 12, 2024

Hi,

i dont't know if this is really a gettext issue but when we cache the _build folder in our GitlLab CI Pipeline the command mix gettext.extract --check-up-to-date although it runs perfectly fine locally.
I suspect some mtime issues because the cache is restored after the repo is cloned.

Any ideas on how to prevent this?

The Job definition
locales:
  stage: lint
  image: $ELIXIR_IMAGE
  cache:
    - key: $CI_COMMIT_REF_SLUG
      paths:
        - _build
    - key:
        files:
          - mix.lock
      paths:
        - deps
  before_script:
    - apk add --no-cache make gcc libc-dev git
    - mix local.rebar --force
    - mix local.hex --force
    - mix deps.get
  script:
    - mix gettext.extract --check-up-to-date
  interruptible: true
  allow_failure: true
@maennchen
Copy link
Member

The extractor is comparing file contents and not using something like mtime:

if IO.iodata_to_binary(PO.compose(merged_po)) == existing_contents do

Can you replace it with a normal extract command and echo a git diff to see the differences?

@kevinschweikert
Copy link
Author

kevinschweikert commented Nov 12, 2024

Thank you!! I found the issue with your suggestions but i stil don't know why it's happening only in CI.

The problem was that we had a ngettext translation with the same singular msgid but a different plural msgid and the default.pot file had only one of these two versions. Strangely, i ran gettext.extract on my local machine which produced an empty diff but in CI i saw this:

$ mix gettext.extract
Compiling 131 files (.ex)
Extracted priv/gettext/default.pot
$ git diff
diff --git a/priv/gettext/default.pot b/priv/gettext/default.pot
index e377ab1..ee57d0c 100644
--- a/priv/gettext/default.pot
+++ b/priv/gettext/default.pot
@@ -1231,7 +1231,7 @@ msgstr ""
 #: lib/app/live/calendar_live.ex
 #, elixir-autogen, elixir-format
 msgid "singular"
-msgid_plural "%{count} plural"
+msgid_plural "other plural"
 msgstr[0] ""
 msgstr[1] ""

I tried with both Elixir 1.16 and 1.17 locally. We're using the latest gettext version 0.26.1

Edit:
Sometimes we could fix it with just rerunning the CI job...maybe sometimes the correct plural msgid got "selected" and it ran sucessfully?

@maennchen
Copy link
Member

maennchen commented Nov 12, 2024

Oh, we should definitely error when different plural messages are provided.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants