Skip to content

Commit

Permalink
Update Translation Assistant
Browse files Browse the repository at this point in the history
  • Loading branch information
danielhollas committed Nov 18, 2020
1 parent 37d0330 commit fc050b4
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 16 deletions.
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "Khan Academy Dots",
"description": "Translate math notation in Khan Academy Crowdin strings.",
"author": "Daniel Hollas & Szymon Bubak & Krzysztof Krystek & Robert Pala",
"version": "3.3.0",
"version": "3.4.0",
"permissions": [
"activeTab",
"storage"
Expand Down
16 changes: 12 additions & 4 deletions options.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ <h3>Please select your language</h3>
<option value="am">Amharic</option>
<option value="ar">Arabic</option>
<option value="hy">Armenian</option>
<option value="as">Assamese</option>
<option value="az">Azerbaijani</option>
<option value="bn">Bengali</option>
<option value="bg">Bulgarian</option>
Expand All @@ -38,22 +39,28 @@ <h3>Please select your language</h3>
<option value="it">Italian</option>
<option value="ja">Japanese</option>
<option value="kn">Kannada</option>
<option value="kk">Kazakh</option>
<option value="km">Khmer</option>
<option value="rw">Kinyarwanda</option>
<option value="ko">Korean</option>
<option value="ky">Kyrgyz</option>
<option value="lv">Latvian</option>
<option value="lt">Lithuanian</option>
<option value="mk">Macedonian</option>
<option value="ms">Malay</option>
<option value="mr">Marathi</option>
<option value="mn">Mongolian</option>
<option value="nb">Norwegian Bokmål</option>
<option value="ps">Pashto</option>
<option value="fa">Persian/Farsi</option>
<option value="pl">Polish</option>
<option value="pt">Brazilian portuguese</option>
<option value="pt-pt">European portuguese</option>
<option value="pa">Punjabi</option>
<option value="ro">Romanian</option>
<option value="ru">Russian</option>
<option value="tr">Turkish</option>
<option value="sr">Serbian</option>
<option value="sl">Slovenian</option>
<option value="so">Somali</option>
<option value="es">Spanish</option>
<option value="sw">Swahili</option>
Expand All @@ -65,6 +72,7 @@ <h3>Please select your language</h3>
<option value="uk">Ukrainian</option>
<option value="ur">Urdu</option>
<option value="uz">Uzbek</option>
<option value="vi">Vietnamese</option>
<option value="xh">Xhosa</option>
<option value="zu">Zulu</option>
</select>
Expand All @@ -74,11 +82,11 @@ <h3>Please select your language</h3>

<br>

<!-- TODO: Update this!-->
<div> Currently supported math notation that will be auto-translated:<br>
<ul>
<li>Decimal point to decimal comma</li>
<li>Thousand separator</li>
<li>Decimal points to decimal commas</li>
<li>Repeating decimals (0.3333... = 0.\overline{3})</li>
<li>Thousand separators</li>
<li>Multiplication</li>
<li>Division</li>
<li>Trigonometry functions</li>
Expand Down
27 changes: 17 additions & 10 deletions pack_plugin.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,26 @@
# or Firefox
# https://addons.mozilla.org/en-US/developers/addon/khan-academy-dots/edit

if [[ -z $1 ]];then
echo "Please, provide browser name (firefox|chrome) as the parameter to this script"
set -eou pipefail

browser=${1-}
if [[ -z $browser ]];then
echo "USAGE: ./pack_plugin.sh <firefox|chrome>"
exit 1
fi

if [[ $1 != "chrome" && $1 != "firefox" ]];then
if [[ $browser != "chrome" && $browser != "firefox" ]];then
echo "Unrecognized browser!"
echo "Please use \"firefox\" of \"chrome\""
exit 1
fi

browser=$1
# Don't forget to bump version in manifest.json before each official publish!
version=$(grep '"version"' manifest.json | awk -F'"' '{print $4}')
REPO_NAME=KhanAcademyDots
PACKAGE_NAME=${REPO_NAME}-${version}-${browser}

cd ../
cd ../ || exit 1

rm -rf $PACKAGE_NAME.zip

Expand All @@ -35,19 +37,24 @@ if [[ ! -d $REPO_NAME ]];then
exit 1
fi

if [[ -d $PACKAGE_NAME ]];then
rm -rf $PACKAGE_NAME
fi

cp -r $REPO_NAME $PACKAGE_NAME

cd $PACKAGE_NAME
cd $PACKAGE_NAME || exit 1
if [[ $? -ne 0 ]];then
echo "ERROR: Could not enter dir ../$PACKAGE_NAME"
exit 1
fi

#sed 's/module.exports/\/\/module.exports/' translation-assistant/lib/math-translator.js > KhanAcademyLibs/math-translator.js
# Get rid of module.exports, which is not supported in browser plugins
# Get rid of module.exports and babel requires,
# which are not supported in browser plugins
nlines=$(grep -n 'module.exports' translation-assistant/lib/math-translator.js | awk -F":" '{print $1;end}')
let nlines--
head -n $nlines translation-assistant/lib/math-translator.js > KhanAcademyLibs/math-translator.js
head -n $nlines translation-assistant/lib/math-translator.js |\
egrep -v 'require(.+)' > KhanAcademyLibs/math-translator.js

rm -rf node_modules/ package.json package-lock.json .eslintrc .git/ *.md pack_plugin.sh translation-assistant/
if [[ $browser = 'chrome' ]];then
Expand All @@ -60,6 +67,6 @@ if [[ $browser = 'chrome' ]];then
fi
zip -r $PACKAGE_NAME.zip *
mv $PACKAGE_NAME.zip ../
cd ..
cd .. || exit 1

rm -rf $PACKAGE_NAME

0 comments on commit fc050b4

Please sign in to comment.