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

Add the '--label' parameter to the 'pre-translate' command #640

Closed
andrii-bodnar opened this issue Sep 13, 2023 · 16 comments · Fixed by #649
Closed

Add the '--label' parameter to the 'pre-translate' command #640

andrii-bodnar opened this issue Sep 13, 2023 · 16 comments · Fixed by #649
Assignees
Labels
enhancement good first issue hacktoberfest This issue welcomes contributions for Hacktoberfest

Comments

@andrii-bodnar
Copy link
Member

Description

Crowdin has recently enhanced the Apply Pre-Translation API to allow passing labels to filter strings for pre-translation.

The new --label option should be added to the crowdin pre-translate command as well.

SYNOPSIS:
crowdin pre-translate [CONFIG OPTIONS] [OPTIONS]

DESCRIPTION:
Pre-translate files via Machine Translation (MT) or Translation Memory (TM)

OPTIONS:
...
      --label=...         Label identifier. Could be specified multiple times
...

It should accept string values of label names. Use should be able to specify multiple labels simultaneously (e.g. crowdin pre-translate --label android --label ios --label web ...)

Additional Context

Similar commands for reference: BundleAddSubcommand, StringAddSubcommand, TaskAddSubcommand.
Documentation:crowdin pre-translate
Blocked by: crowdin/crowdin-api-client-java#188

@andrii-bodnar andrii-bodnar added enhancement good first issue hacktoberfest This issue welcomes contributions for Hacktoberfest labels Sep 13, 2023
@debanjanc01
Copy link
Contributor

Hey @andrii-bodnar is this up for grabs?

@andrii-bodnar
Copy link
Member Author

Hi @debanjanc01, sure, would you like it to be assigned to yourself?

@andrii-bodnar
Copy link
Member Author

UPD: need to update the crowdin-api-client-java to the 1.11.4 version

@debanjanc01
Copy link
Contributor

@andrii-bodnar I'll give a go at this.

@debanjanc01
Copy link
Contributor

debanjanc01 commented Oct 3, 2023

Hey @andrii-bodnar is the crowdin-api-client-java 1.11.4 available on jitpack.io? I'm unable to find it.
https://jitpack.io/com/github/crowdin/crowdin-api-client-java/1.11.4/build.log

Going by the build.log, it seems that the artifact wasn't pushed to remote.

Found artifact: com.github.crowdin:crowdin-api-client-java:1.11.4
Found artifact: :crowdin-api-client-java:1.11.4
ERROR: Time-out getting container status
Error building

I've attached the build.log file for reference.
jitpack.io_com_github_crowdin_crowdin-api-client-java_1.11.4_build.log

@andrii-bodnar
Copy link
Member Author

@debanjanc01 thanks for noticing that!

There was indeed some build error. I just deployed a new version - 1.11.5

@debanjanc01
Copy link
Contributor

Hey @andrii-bodnar I can see the artifacts are available now for 1.11.5

I'll update the version accordingly then to 1.11.5

@debanjanc01
Copy link
Contributor

debanjanc01 commented Oct 4, 2023

@andrii-bodnar can you please confirm if the Pre Translate expects labels as String or Integer?
The ApplyPreTranslationRequest.java in crowdin-api-client-java also takes in List of integers.

@andrii-bodnar
Copy link
Member Author

@debanjanc01 the --label parameter should accept a string. It means that before making an API call, we need to additionally collect IDs based on the passed label names.

@debanjanc01
Copy link
Contributor

@andrii-bodnar got it. Could you help me understand where to collect/translate the IDs from? Is there an existing mapping I can refer to? I'm unable to find something similar on the codebase

@andrii-bodnar
Copy link
Member Author

@debanjanc01 you need to use the listLabels method.

Please refer to the following commands for reference: BundleAddSubcommand, StringAddSubcommand, TaskAddSubcommand. These commands already contain the exact same functionality.

@debanjanc01
Copy link
Contributor

Hey @andrii-bodnar found it! Thanks!

@debanjanc01
Copy link
Contributor

Hey @andrii-bodnar , I've raised the PR. Please have a look and let me know.
Also, we could put the prepareLabelIds method as a Util and use it in all actions that use it, rather than duplicating code. What do you think?

@andrii-bodnar
Copy link
Member Author

@debanjanc01 thank you!

Yes, it would be great to extract this method to avoid code duplication

@debanjanc01
Copy link
Contributor

@andrii-bodnar shall I make it a part of the src/main/java/com/crowdin/cli/utils/Utils.java class?

@andrii-bodnar
Copy link
Member Author

@debanjanc01 yes, I think this class is a good candidate. If possible, it would be good to have a Unit test as well for this method

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement good first issue hacktoberfest This issue welcomes contributions for Hacktoberfest
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants