Anki-Android
Anki-Android copied to clipboard
[Deprecation] Move to new Crowdln API
We should move to API 2.0 before the end of the year
Hello! 👋 Thanks for logging this issue. Please remember we are all volunteers here, so some patience may be required before we can get to the issue. Also remember that the fastest way to get resolution on an issue is to propose a change directly, https://github.com/ankidroid/Anki-Android/wiki/Contributing
That's unfortunate, already plenty to do but it is always something in a large project :-) Thanks for logging this.
Can I take this issue?
Can I take this issue?
This may be complex - I feel it might be better if you take a different issue while you're getting used to the project
Hello 👋, this issue has been opened for more than 2 months with no activity on it. If the issue is still here, please keep in mind that we need community support and help to fix it! Just comment something like still searching for solutions and if you found one, please open a pull request! You have 7 days until this gets closed automatically
They have a javascript client which has examples on the README detailing pretty much exactly what we need to do
https://support.crowdin.com/api/v2/#section/Introduction/Crowdin-API-Clients
https://github.com/crowdin/crowdin-api-client-js
They also have other languages available, but as a scripting language I'd prefer to use typescript these days. It has the widest developer pool so most people know it, it comes in handy when cross-training for our github actions scripts, and we use it as a front-end web technology as well in the Anki ecosystem.
I suggest making a sub-directory in whatever the location is of the current script, and that subdirectory is a typescript module with package.json and everything. Execute ts-node, alter the github action to do a yarn
in that sub-directory to install packages then the same ts-node execute on the script
The hard part here will be testing. I suggest making a new temporary crowdin project on a temporary fork, then porting the current Python "file push to crowdin" to the new typescript equivalent and making sure that crowdin sees the files in the right spot so we have continuity with the real project. Then port the "build project and download project" python to the typescript equivalent, then run our post-processing scripts as they are and push to the i18n_sync branch like in current github action
Not sure I'll have time to do this, but I did the research at least and that's the sketch I'd follow.
Incremental development and testing testing testing each feature. using a second temp project from a temp fork means you don't have to worry about official access tokens or anything, you can create them yourself as temp project owner so there's no blocker and no chance of messing up the main crowdin translations
Would probably need to check with CrowdIn support about getting the test project verified as open source, we're very close to the 60k strings limit which pushes you to paid territory if you're not an open source app
As long as it's done quickly, no worries ;-). test could also just skip-on-purpose a couple files as long as they were in the same path location (like, to 01 through 05, skip 06-10 or whatever). The test needs to be representative, not complete IMHO
I will give it a try.
Champion :trophy: ! let me know if you need any advice or anything, this is so important to project continuity that I really want to see this get done and I will help any way I can
Okay, Thanks
@mikehardy @david-allison
I have updated this shell script to find broken strings. The typescript approach is slower and may not catch the expected errors.
This is added in below script.
'<!--'
'%d%%'
'%s%%'
'%1$d%%'
'%1$.1f'
'%1$.2f'
'%2$.2f'
'%3$.1f'
Will this script handle the expected errors?
#!/bin/bash
# Spot malformed string replacement patterns in Android localization files.
# Hopefully it will prevent this kind of bugs: https://code.google.com/p/ankidroid/issues/detail?id=359
# shellcheck disable=SC2016
EXIT_STATUS=0
VALUES=res/values/10-preferences.xml
pushd AnkiDroid/src/main > /dev/null || exit 1
if grep -RHn "%1$ s" $VALUES; then
echo "Found '%1$ s'-related error"
EXIT_STATUS=$((EXIT_STATUS + 1));
fi
if grep -RHn "%1$ d" $VALUES; then
echo "Found '%1$ s'-related error"
EXIT_STATUS=$((EXIT_STATUS + 1));
fi
if grep -RHn "%1" $VALUES | grep -v "%1\\$"; then
echo "Found '%1'-related error"
EXIT_STATUS=$((EXIT_STATUS + 1));
fi
# This is currently not working and I'm not sure why? It worked a couple days ago as of 20200516
echo "The next test will likely only run correctly on macOS. On Ubuntu it does not work well."
if grep -RHn '%' $VALUES |
grep -v '<!--' | # Filter comments
grep -v '%d%%' |
grep -v '%s%%' |
grep -v '%1$d%%' |
grep -v 'pref_summary_percentage' |
sed -e 's/%/\n%/g' | # Split lines that contain several expressions
grep '%' | # Filter out lines that do not contain expressions
grep -v ' n% ' | # Lone % character, not a variable
grep -v '(n%)' | # Lone % character, not a variable
grep -v 'n%<' | # Same, at the end of the string
grep -v '>n% ' | # Same, at the beginning of the string
grep -v '%で' | # Same, no spaces in Japanese
grep -v '%s' | # Single string variable
grep -v '%d' | # Single decimal variable
grep -v '%[0-9][0-9]\?$s' | # Multiple string variable
grep -v '%[0-9][0-9]\?$d' | # Multiple decimal variable
grep -v '%1$.1f' | # ?
grep -v '%1$.2f' |
grep -v '%2$.2f' |
grep -v '%3$.1f' |
grep -v '%.0f' |
grep -v '%.1f' |
grep -v '%\\n' |
grep -v 'stats_overview_card_types_'
then
echo "Found grep errors in $VALUES"
EXIT_STATUS=$((EXIT_STATUS + 1))
fi
if grep -RHn '%' $VALUES; then
echo "Found errors in simple '%' grep"
EXIT_STATUS=$((EXIT_STATUS + 1));
fi
if grep -RHn "CDATA " $VALUES; then
echo "Found CDATA-related errors"
EXIT_STATUS=$((EXIT_STATUS + 1));
fi
${ANDROID_HOME}/cmdline-tools/latest/bin/lint --check StringFormatInvalid ./res
popd > /dev/null || exit 1
echo "Exiting with status $EXIT_STATUS"
exit $EXIT_STATUS
The lint catch the errors that I am trying to implement in check.ts
file.
The following lint check errors in localized strings also and it is faster.
Check string format errors like %1$ s
(space after $) and other errors in <string>
lint --check StringFormatInvalid ./res
Check error for %1 $s
(space after %1)
lint --check StringFormatCount ./res
Check if localized string contains one
, few
, many
, other
for quantity strings
lint --check MissingQuantity ./res
In these locales, it is usually an error to have a message which does not include a formatting argument (such as '%d'), since it will not be clear from the grammar what quantity the quantity string is describing.
lint --check ImpliedQuantity ./res
I think the lint
should be used.
http://tools.android.com/tips/lint-checks