crowdin / crowdin-cli-v1 Goto Github PK
View Code? Open in Web Editor NEWA command-line client for the Crowdin API v1
License: MIT License
A command-line client for the Crowdin API v1
License: MIT License
Hi!
Unfortunately we dont have a
translations/
en/somefile.xlf
de/somefile.xlf
structure, but instead we have the locale on the filenames, like this:
translations/
somefile.en.xlf
somefile.de.xlf
Is there any way how i can configure source
and translation
on the corwdin.yaml so this will work?
In CyanogenMod we usually have a common base_path (/android) that contains subfolders of each version. (/android/cm-12.1, ~/android/cm-13.0, etc.)
It would be very useful to have support for a common base_path using the new branch feature in crowdin, so we don't have to specify a different base_path for each CyanogenMod version (we use different yaml configs for different versions, as the packages are different)
I think this was already implemented but commented out in crowdin-cli if I understand right. I will try to make it an option, if it works I'm going to make a pull request.
I have a source file that is a .csv file. The .yaml config for that source file is:
source: '/fastlane/metadata/**/en-US/*.csv'
translation: '/fastlane/metadata/**/%two_letters_code%/%original_file_name%'
first_line_contains_header: false
scheme: "identifier,source_or_translation"
Updating the file manually in the web interface works correctly, so the file is valid. However, when using the command crowdin-cli upload sources
, there is a problem. The file seems to be uploaded correctly - there is no error message. However, when I go to the website and look at the file (that did previously have a string in it) it is now empty - the history on the file says that 1 string was deleted, and it has the text 'Nothing to translate' in the website's file browser.
As in #15, using an absolute path as base_path is not the correct solution. I guess it's easy to add support for base_path in the user-specific yaml file, like we can currently do with api_key.
This is needed for our project (CyanogenMod) since a lot of people use the script checked out in different locations.
I have a project in Crowdin that's being translated into French (fr), Spanish Mexico (es-MX), and Spanish Spain (es-ES). I'm running into an issue where if I defined my configuration to use %locale%
the translations for French have fr-FR
in the name (which causes C# to fallback if the locale is fr-CA
for example) but if I use %two_letters_code%
I only get files with es
in the name. If I manually download the files they have the correct codes (fr, es-MX, and es-ES).
Is there anyway to setup my configuration so my files download using either the two letter code or the full locale based on the project?
Use case :
I add a new translation language from Crowdin website, and do the translations. When a developer use the crowdin-cli download
, the new language folder won't exist yet, and the command won't create folders / files associated. It should be the case to simplify workflow and avoid developer to create a multitude of files / folders to match the new locale.
Example:
files:
-
source: '/path/to/*.properties'
translation: '/path/%two_letters_code%/%two_letters_code%'
//
dest: '/path/in/crowdin/*.properties'
// or
dest: '/path/in/crowdin/%original_file_name%'
Hey,
When I download translations from my crowdin project using crowdin-cli, pluralized keys used by rails-18n are missing, resulting in a tree like this:
users:
one: "1 user" # this one is missing
other: "%{count} users"
This is an issue because rails-i18n can't fallback on 'other'. I'm using preverse_hierarchy: true
.
It may be nice to be able to replicate 'other' values as 'one' to avoid breakages.
We are using crowdin.yaml file with crowdin-cli for automated upload and download of translations.
file looks something like this:
files:
-
source: /res/values/strings.xml
translation: /res/values-%android_code%/%original_file_name%
languages_mapping:
android_code:
de-rDE: de
es-rES: es
and as result we get all translation in folders like :
values-de-rDe
values-es-rES
values-fr-rFR
is there any mapping or some other way to get translations in folders like
values-de
values-es
values-fr-rFR
Uploading /home/mama/ruby/crowdin/crowdin-cli/test/ru/share/site-webscripts/org/alfresco/modules/header/sites.get.properties
error: 8: File not found
I was using the latest version of crowdin-cli (at commit a8d20c1) and I encountered this error message:
Extracting: `/packages/apps/Settings/res/values-ro-rRO/arrays.xml'
error: can't convert Zip::Entry into String
Failed to run cmd: crowdin-cli --config=crowdin/crowdin.yaml download -b branch
The error message was resolved once I reverted f687e31. I believe that this should be a simple fix, however since I have 0 experience with Ruby, so this is the most I can help with. Thank you.
In our application we use environment variables for storing sensitive credentials.
It would be great if the crowdin.yaml file could support ERB so that we could load the API key from an environment variable, e.g.
api_key: <%= ENV["CROWDIN_API_KEY"] %>
Is it possible change a source string and upload it without loosing the translations?
I'm using an Android project where one source string, in english, has a mistake. I believe that changing the source and uploading to CrowdIn (I use the crowdin-cli upload sources command), all translations will be lost for that string. Is that correct ?
I have a csv file to upload using the command line that has 2 columns - "Identifier (Key)" and "Source String/Translation". In the documentation of the config file's csv scheme
field there is no mention of how to specify the source/translation column type. If you dont specify it correctly in the config file you will get an error when running crowdin-cli upload sources
:
"File schema must include the "Source String" and "Translation" options."
For those that are also getting this error and stumped by the documentation, I found the solution:
source_or_translation
I found it by using the browser's developer tools, and watching network activity when saving a template on the crowdin website.
When trying to download a large project that creates a new export, a request can take a long time (in the case that I am seeing ~60 minutes). When this happens, the cli client keeps the connection open and expects it to remain intact while idle.
This doesn't work behind a lot of firewalls or NAT gateways that have idle connection time limits (AWS NAT Gateway specifically has a 5 min limit and is the one that triggered this issue for us). When this happens and the connection is drop'ed in the middle without a corresponding RST being sent (which is a separate kind of wrong) the client thinks the connection is still up and waits patiently forever to hear back from the remote.
Please support TCP keepalives for http connections in order to avoid this issue. When inspecting the TCP socket the keepalive flag is not added. For the short term we were able to work around the issue with https://github.com/flonatel/libdontdie
It looks like the HTTP handling comes from rest-client, which has a few keepalive patches that are not merged but currently no support for this feature.
Currently, it prevents to upgrade rubyzip to 1.2.1, which contains a security fix: https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2017-5946
Only works with Ruby 1.x and not 2.x (at least on Windows)
It used to work, I'm not sure what changed since. My yaml file (iOS project):
project_identifier: REDACTED
api_key: REDACTED
base_path: .
files:
- source: "/Resources/en.lproj/*"
translation: "/Resources/%osx_code%/%original_file_name%"
languages_mapping:
osx_code:
es-MX: es.lproj
pt-BR: pt.lproj
zh-CN: zh-Hans.lproj
zh-TW: zh-Hant.lproj
My files on crowdin are set to be exported following this format: /Resources/%osx_code%/%original_file_name%
All languages without mapping (like en
) are put in their correct place. Languages with mapping (like es-MX
) are not. I get an error like this:
$> crowdin-cli download
...
Warning: Downloaded translations do not match current project configuration. The following files will be omitted:
- `Resources/zh-Hans.lproj/Localizable.strings'
- `Resources/zh-Hans.lproj/Localizable.stringsdict'
- `Resources/zh-Hans.lproj/InfoPlist.strings'
- `Resources/zh-Hant.lproj/Localizable.strings'
- `Resources/zh-Hant.lproj/Localizable.stringsdict'
- `Resources/zh-Hant.lproj/InfoPlist.strings'
- `Resources/pt-BR.lproj/Localizable.strings'
- `Resources/pt-BR.lproj/Localizable.stringsdict'
- `Resources/pt-BR.lproj/InfoPlist.strings'
- `Resources/es-MX.lproj/Localizable.strings'
- `Resources/es-MX.lproj/Localizable.stringsdict'
- `Resources/es-MX.lproj/InfoPlist.strings'
... // other branches shows too like - `branch-name/Resources/pt-BR.lproj/InfoPlist.strings'
My local project file structure looks like this:
If I build and download from Crowdin website the structure looks like this:
Wondering if it's due to branches, in my example I do crowdin-cli download
without branch param
We are translating a software that is divided into a core and several plugins. Some of the plugins are treated as 'core plugins' and some are not. The core plugins should be translated on Crowdin, so I added the corresponding regex to the yaml config (e.g. plugins/**/locale/messages.json
).
Is there currently a way to specify certain URL patterns to be excluded or ignored from crowdin-cli, comparably to the .git/info/exclude file?
This is my crowdin yml configuration:
project_identifier: ....
api_key: ...
base_path: ...
files:
-
source: '/app/src/main/res/values/strings.xml'
translation: '/app/src/main/res/values-%android_code%/%original_file_name%'
translate_attributes: '0'
This is my website configuration:
After running java -jar crowdin-cli.jar download
all the files are downloaded in the following format:
But when trying to compile the project I get the following error:
- app/src/main/res/values-kab-rKAB: Error: Invalid resource directory name
It seems like some of the language codes are incorrect and cause compilation errors.
When I use the 2 letters code it works, but it causes me to loose some of the translation languages.
Is this a known error and is there a solution?
Currently crowdin-cli
shows file names that doesn't match configuration when download
command is executed.
The simplest solution would be to add an optional argument to crowdin download
.
E.g. --ignore-unmatch
(false
by default)
I use this mapping:
languages_mapping:
android_code:
af: af
ar: ar
be: be
ca: ca
cs: cs
da: da
de: de
el: el
es: es
et: et
fi: fi
fr: fr
gl: gl
iw: iw
hi: hi
hr: hr
hu: hu
in: in
it: it
iw: iw
ja: ja
ko: ko
lt: lt
nl: nl
no: no
pl: pl
ro: ro
ru: ru
sk: sk
sl: sl
sr: sr
sv: sv
tr: tr
uk: uk
vi: vi
But receive this:
why is for example es not properly mapped although mapping is given?
So, the description says Download latest translations from Crowdin
. But what does that mean in practice?
In my opinion, it should download the files that are not part of any branch. So, for example. If I only have one file (let's call it mainFile
) and then multiple branches of the same file. When I do crowdin-cli download
I expect to get mainFile
in the same way that if I do crowdin-cli download -b branch
I get the file for that branch. But that's definitely not happening, I'm not even sure what things are been downloaded.
Could someone please clarify?
Thanks
Currently the crowdin.yaml file contains project-specific configuration and user credentials (api_key
). This means that you can't commit this file in the code repository, because the API key would leak to other users. It would be great if crowdin-cli would allow 2 configuration files:
I am having a json like
{
"English" : ""
}
Here I want to get this file updated with another language content via some program.
Is there any java based solution for this?
Couldn't figure out why the newest translation files weren't downloading (the downloaded file didn't contain the latest changes). Ran the tool in verbose mode
crowdin-cli -v download -l ru >/tmp/debug.txt 2>&1
and noticed {"status":"skipped"}
. The export api docs mention Please note that this method can be invoked only once for 30 minutes.
It would be nice if crowdin-cli
would warn that export was skipped, so that it would be clear that I should try to download the latest changes later.
Given this crowdin.yaml
file:
project_identifier: poedit
base_url: http://api.crowdin.net
base_path: .
files:
-
source: /locales/poedit.pot
translation: /locales/%two_letters_code%.po
languages_mapping:
two_letters_code:
ckb: ckb
en-GB: en_GB
pt-BR: pt_BR
val-ES: ca@valencia
zh-CN: zh_CN
zh-TW: zh_TW
Uploading the translations with crowdin-cli upload translations --auto-approve-imported --import-eq-suggestions
(after uploading the POT file first) fails with
Warning: Skip `/locales/cs.po'
etc. After a while, I realized the problem is in the base_path
. If I omit it (which has the same effect, because pwd is the default), it works. But then, I get the annoying Configuration file misses parameter base_path
that defines your project root directory warning on every invocation.
Using an absolute path as base_path
takes care of both, but that's not usable in practice: I cannot commit absolute path to the (public) repository, because different people may have it checked out in different locations (even I alone have different checkouts with different paths).
Not sure where this difference between .
and absolute pwd comes from, perhaps the tool should absolutize any relative base_path
first?
If I try to upload a branch like somehow/new-feature-branch
with crowdin-cli upload sources -b somehow/new-feature-branch
I get the error:
Creating a new branch `somehow/new-feature-branch'error: 17: Specified directory was not found
crowdin-cli
should work on Windows and should be installable as a gem
I can easily create mapping for translations.
We are a open source community project. In case people come and help for translation, we have some languages open in our crowdin page. Couple of them have 0% translation.
I want to ignore them when I am downloading from crowd-in. As far as I understand, it is impossible right now.
-- Java -- :
openjdk 12 2019-03-19
OpenJDK Runtime Environment (build 12+33)
OpenJDK 64-Bit Server VM (build 12+33, mixed mode, sharing)
-- OS -- :
System Version: macOS 10.14.3 (18D109)
Kernel Version: Darwin 18.2.0
-- CLI -- :
crowdin: stable 2.0.28
$ crowdin upload sources --config crowdin.yml
WARNING: sun.reflect.Reflection.getCallerClass is not supported. This will impact performance.
Exception in thread "main" java.lang.ExceptionInInitializerError
at com.crowdin.cli.commands.Commands.initCli(Commands.java:858)
at com.crowdin.cli.commands.Commands.initialize(Commands.java:128)
at com.crowdin.cli.commands.Commands.run(Commands.java:232)
at com.crowdin.cli.Cli.main(Cli.java:17)
Caused by: java.lang.UnsupportedOperationException: No class provided, and an appropriate one cannot be found.
at org.apache.logging.log4j.LogManager.callerClass(LogManager.java:555)
at org.apache.logging.log4j.LogManager.getLogger(LogManager.java:580)
at org.apache.logging.log4j.LogManager.getLogger(LogManager.java:567)
at com.crowdin.client.CrowdinApiClientImpl.<clinit>(CrowdinApiClientImpl.java:22)
... 4 more
It's seems to be issue of compatibility with my java version. I got it working with
java version "1.8.0_202"
Java(TM) SE Runtime Environment (build 1.8.0_202-b08)
Java HotSpot(TM) 64-Bit Server VM (build 25.202-b08, mixed mode)
As I prefer to use the latest SDK system wide, i'm using jenv to set the java version inside the folder where I use crowdin.
I would expect to see it working if I have an api_key
in the local crowdin.yaml
to be respected first and then check if there is any api key in the ~/.crowdin.yaml
Thanks for the project!
I would really appreciate if you could add tags to mark release versions - that would ease searching and making diffs.
Currently, crowdin-cli search for a crowdin.yaml
file. crowdin.yml
should be an searched too if not found
Invoking
java -jar crowdin-cli.jar upload --import-eq-suggestions translations
returns an error message
error: Unknown option --import-eq-suggestions
Below it says (excerpt):
SYNOPSIS
<script> [global options] upload [--auto-update] sources
<script> [global options] upload [--auto-approve-imported] [--import-duplicates] [--import-eq-suggestions] [-l crowdin_language_code|--language crowdin_language_code] translations
Seems to be valid usage for me... has this option been removed?
Using crowdin-cli 0.25 downloaded from crowdin.net, on Windows 8, with Java 7.
Hi,
i wanna know if there's a way to upload sources strings and tell crowdin to not apply translations if i already have those.
Sometimes i've to update my source file with different keys but i don't want crowdin automatically apply translations (this is the reason why i wanna create new keys instead of using what i already have).
Something like --import-duplicates
or similar but for the source strings.
We're using CircleCI for deployment/tests and we stumbled upon a problem this WE : we couldn't deploy because crowdin-cli wouldn't install.
We needed to add specific version of dependencies which upgraded, to not support 1.9 anymore
Use those lines (in CircleCI in a :before_deploy block) to restore a proper install, or restrict those in the GemFile :)
gem install mime-types -v 2.6.2
gem install rest-client -v 1.8
Cheers and keep it up !
Just installed RVM with Ruby 2.3.0 and the only gem installed is crowdin-cli.
After running crowdin-cli download sources for example, it takes around 10 minutes to complete the operation. Using strace, I can see the whole directory is being scanned even if the configuration YAML file tells which path to look for translations.
Very simple crowdin.yaml file:
files:
-
source: /resources/lang/default/*.php
translation: /resources/lang/%two_letters_code%/%original_file_name%
Hello,
I have a little issue to download files with languages_mapping from %locale%
to %two_letters_code%
.
I'm not sure this is an issue or voluntary on your part.
This i my config file:
files:
-
source: 'en/file.json'
translation: '%two_letters_code%/%original_file_name%'
languages_mapping:
two_letters_code:
# crowdin_language_code: custom_code
'es-ES': 'es'
What happened when I start download:
Build ZIP archive with the latest translations - Skipped
Warning: Export was skipped. Please note that this method can be invoked only once per 30 minutes.
Download: `nl/file.json'
Download: `fr/file.json'
Warning: Downloaded translations do not match current project configuration. Some of the resulted files will be omitted.
- `es-ES/file.json'
I've been having a lot of trouble catching errors related to crowdin-cli in CI because whenever there's an error and it exits, it always uses exit code 0 (success).
For example, crowdin --config does_not_exist.yml upload sources && echo "Success!"
will in fact print success.
Can't find info about difference/usage of identifier and source_phrase in CSV format.
Found some description https://support.crowdin.com/api/add-file/ but don't know what to put in them
We have so many issues with (new) developers ulpoading from an outdated source file and erasing keys. It would be really nice if the cli could ask confirmation when erasing keys. It doesn't have to be the default behaviour, could be enabled with a flag in crowdin.yml.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.