Github integration adding comments on the wrong line

We use the Github integration for a Rails project, and recently it has started inserting comments on the wrong line. Here’s a commit from the integration showing this. I’m guessing this is a bug? The only recent change on our end was to add that comment on the subsequent line.

Hi @kueda
This is the string from the Editor with the same context as being added in the shared config

As you can see from the Translation history of the same string the context was changed from "root -> activerecord -> errors -> models -> moderator_action -> attributes -> base -> only_staff_and_hiding_curators_can_unhide" to
"root -> activerecord -> errors -> models -> moderator_action -> attributes -> base -> only_staff_and_hiding_curators_can_unhide Error saying that only admin users (staff) can set resources as private"as it is in the commit

Yes, the change in context to only_staff_and_curators_can_hide was intentional on our end. The problem on your end is that even though only_staff_and_hiding_curators_can_unhide was translated into Czech and has no context comment, the Crowdin Github integration inserted another string’s context comment on the same line.

i.e. it committed this:

only_staff_and_hiding_curators_can_unhide: Pouze zaměstnanci a kurátoři, kteří skryjí obsah, jej mohou znovu odkrýt #Error saying that only admin users (staff) can set resources as private

when it should have committed this:

only_staff_and_hiding_curators_can_unhide: Pouze zaměstnanci a kurátoři, kteří skryjí obsah, jej mohou znovu odkrýt

because only_staff_and_hiding_curators_can_unhide has no context comment. Even if it did, the comment should appear above the line, not at the end of it.

Aside: it would be great if there were an option to strip comments from output files.

Hi @kueda

I’m not sure there’s an issue here since context is added at the source string level, i.e. this string will have the same context in all target languages. From my side, I see this as string context:

root -> activerecord -> errors -> models -> moderator_action -> attributes -> base -> only_staff_and_hiding_curators_can_unhide
Error saying that only admin users (staff) can set resources as private

Please double-check the way you add context to the source strings. Sample YAML file can be found here:

As for modification, you can use this application to manipulate Json and Yaml files (Configurable JSON/YAML translation with Crowdin).

Or you can develop your import-export processing rules and cut off all context on the export for example:

Please double-check the way you add context to the source strings. Sample YAML file can be found here:

That example looks like this:

en:

  first_key: "String for translation 1" #Context for string 1 

We’ve been using YAML with Crowdin for years and we have never done this. We always put context of the preceding line, e.g.

en:
  # Context for string 1 
  first_key: "String for translation 1"

and that has never resulted in comments getting appended to content lines until now, so I’m not sure what changed. We can adjust to your recommended approach but it will be a pain, plus it makes the YAML file hard to read for humans when the context comment is long.

FWIW, I just re-arranged that part of the source file so keys and values are on the same line and the appended comments in the output files went away, so maybe that was the source of our issue. We were doing this:

only_staff_and_hiding_curators_can_unhide:
  Only staff and curators who hide content can unhide it
# Error saying that only admin users (staff) can set resources as private
only_staff_can_make_private:
  Only staff can set content as private

and this removes the problem:

only_staff_and_hiding_curators_can_unhide: Only staff and curators who hide content can unhide it
# Error saying that only admin users (staff) can set resources as private
only_staff_can_make_private: Only staff can set content as private

I suspect using pipes might also remove the problem:

only_staff_and_hiding_curators_can_unhide: |
  Only staff and curators who hide content can unhide it
# Error saying that only admin users (staff) can set resources as private
only_staff_can_make_private: |
  Only staff can set content as private

Anyway, thanks again for your input. We may look into one of those export processing solutions you mentioned.

Hi @kueda ,

Thank you for sharing your findings regarding the context comments in the YAML files.

Sure thing, you are welcome to check the processing modules. They can be used for both import and export, so you can receive a great solution.

If anything else will be needed - we’re here to assist you in ensuring your localization process runs smoothly :slight_smile: