diff --git a/.gitignore b/.gitignore index ff26515..a12b2d8 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,7 @@ node_modules/ promo/*.png !promo/blue_promo.png scripts/locales/html/*.html +scripts/locales/js/_files.txt scripts/locales/js/*.js scripts/locales/locales.js web-ext-artifacts/ \ No newline at end of file diff --git a/_locales/en/messages.json b/_locales/en/messages.json index d20e41e..040b5db 100644 --- a/_locales/en/messages.json +++ b/_locales/en/messages.json @@ -64,9 +64,6 @@ "hideMoreTweetsLabel": { "message": "Hide \"Discover more\" tweets" }, - "sharedTweetsOptionsLabel": { - "message": "Tweets shared by other users" - }, "retweetsLabel": { "message": "Retweets" }, diff --git a/_locales/es/messages.json b/_locales/es/messages.json index 6ba6c47..dcf253b 100644 --- a/_locales/es/messages.json +++ b/_locales/es/messages.json @@ -64,9 +64,6 @@ "hideMoreTweetsLabel": { "message": "Ocultar tweets de \"Ver más\"" }, - "sharedTweetsOptionsLabel": { - "message": "Tweets compartidos por otros usuarios" - }, "retweetsLabel": { "message": "Retweets" }, diff --git a/_locales/ja/messages.json b/_locales/ja/messages.json index 6d62d37..97155e0 100644 --- a/_locales/ja/messages.json +++ b/_locales/ja/messages.json @@ -64,9 +64,6 @@ "hideMoreTweetsLabel": { "message": "ツイートの「もっと見る」を非表示" }, - "sharedTweetsOptionsLabel": { - "message": "他のユーザーが共有したツイート" - }, "retweetsLabel": { "message": "リツイート" }, diff --git a/scripts/locales/README.md b/scripts/locales/README.md index 9c5831f..01802bf 100644 --- a/scripts/locales/README.md +++ b/scripts/locales/README.md @@ -1,11 +1,17 @@ ## Updating Locales -Tweak `html/_files.txt` if needed to add new locales. +### Get locale files from Twitter -In `html/` run `curl -K _files.txt` to retrieve HTML from Twitter with the latest URLs for hashed locale files. +> Tweak `html/_files.txt` and `create-js-curl-config.js` first if locales have changed. -Use the contents of the HTML files to update `js/_files.txt` - left as an exercise for the reader. +```sh +(cd html && curl -K _files.txt) +node create-js-curl-config.js +(cd js && curl -K _files.txt) +``` -In `js/` run `curl -K _files.txt` to retrieve locale files. +### Create locale object for tweak-new-twitter.user.js -Run `node create-locales.js` to create a `locales.js` file and use it to update `tweak-new-twitter.user.js`. +Run `node create-locales.js` to create `locales.js`. + +Open it, save to format it with Prettier, then use its contents to update `tweak-new-twitter.user.js`. diff --git a/scripts/locales/create-js-curl-config.js b/scripts/locales/create-js-curl-config.js new file mode 100644 index 0000000..455066c --- /dev/null +++ b/scripts/locales/create-js-curl-config.js @@ -0,0 +1,23 @@ +const fs = require('fs') +const path = require('path') + +let curlConfig = '' +for (let file of fs.readdirSync('./html')) { + if (!file.endsWith('.html')) continue + let localeCode = file.split('.')[0] + let html = fs.readFileSync(path.join('html', file), {encoding: 'utf8'}) + let match = html.match( + new RegExp( + `https://abs\\.twimg\\.com/responsive-web/client-web-legacy/i18n/${localeCode}\\.(?:[a-z\\d]+)\\.js` + ) + ) + + if (!match) { + console.log('could not find locale file URL', {file, localeCode}) + continue + } + + curlConfig += `-o ${localeCode}.js\nurl="${match[0]}"\n` +} + +fs.writeFileSync('./js/_files.txt', curlConfig) diff --git a/scripts/locales/create-locales.js b/scripts/locales/create-locales.js index c7ebfcd..e07f988 100644 --- a/scripts/locales/create-locales.js +++ b/scripts/locales/create-locales.js @@ -231,6 +231,6 @@ for (let file of fs.readdirSync('./js')) { locales[localeCode] = sortProperties(locale) } -fs.writeFileSync('locales.js', JSON.stringify(locales, null, 2), { +fs.writeFileSync('locales.js', 'let locales = ' + JSON.stringify(locales, null, 2), { encoding: 'utf8', }) diff --git a/scripts/locales/js/.gitkeep b/scripts/locales/js/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/scripts/locales/js/_files.txt b/scripts/locales/js/_files.txt deleted file mode 100644 index 551666d..0000000 --- a/scripts/locales/js/_files.txt +++ /dev/null @@ -1,94 +0,0 @@ --o ar-x-fm.js -url="https://abs.twimg.com/responsive-web/client-web-legacy/i18n/ar-x-fm.9b6d9625.js" --o ar.js -url="https://abs.twimg.com/responsive-web/client-web-legacy/i18n/ar.c56a3655.js" --o bg.js -url="https://abs.twimg.com/responsive-web/client-web-legacy/i18n/bg.c7daf475.js" --o bn.js -url="https://abs.twimg.com/responsive-web/client-web-legacy/i18n/bn.36541a45.js" --o ca.js -url="https://abs.twimg.com/responsive-web/client-web-legacy/i18n/ca.dd43afd5.js" --o cs.js -url="https://abs.twimg.com/responsive-web/client-web-legacy/i18n/cs.243cb7c5.js" --o da.js -url="https://abs.twimg.com/responsive-web/client-web-legacy/i18n/da.0648a375.js" --o de.js -url="https://abs.twimg.com/responsive-web/client-web-legacy/i18n/de.98f5e105.js" --o el.js -url="https://abs.twimg.com/responsive-web/client-web-legacy/i18n/el.cdea0145.js" --o en.js -url="https://abs.twimg.com/responsive-web/client-web-legacy/i18n/en.a31bf535.js" --o es.js -url="https://abs.twimg.com/responsive-web/client-web-legacy/i18n/es.2465ea15.js" --o eu.js -url="https://abs.twimg.com/responsive-web/client-web-legacy/i18n/eu.38342ee5.js" --o fa.js -url="https://abs.twimg.com/responsive-web/client-web-legacy/i18n/fa.862946c5.js" --o fi.js -url="https://abs.twimg.com/responsive-web/client-web-legacy/i18n/fi.481d4b35.js" --o fil.js -url="https://abs.twimg.com/responsive-web/client-web-legacy/i18n/fil.1f715a55.js" --o fr.js -url="https://abs.twimg.com/responsive-web/client-web-legacy/i18n/fr.713e97b5.js" --o ga.js -url="https://abs.twimg.com/responsive-web/client-web-legacy/i18n/ga.489c5605.js" --o gl.js -url="https://abs.twimg.com/responsive-web/client-web-legacy/i18n/gl.ce1202e5.js" --o gu.js -url="https://abs.twimg.com/responsive-web/client-web-legacy/i18n/gu.578860b5.js" --o he.js -url="https://abs.twimg.com/responsive-web/client-web-legacy/i18n/he.3da1c4c5.js" --o hi.js -url="https://abs.twimg.com/responsive-web/client-web-legacy/i18n/hi.d9e089f5.js" --o hr.js -url="https://abs.twimg.com/responsive-web/client-web-legacy/i18n/hr.458854c5.js" --o hu.js -url="https://abs.twimg.com/responsive-web/client-web-legacy/i18n/hu.ec54a955.js" --o id.js -url="https://abs.twimg.com/responsive-web/client-web-legacy/i18n/id.11745ed5.js" --o it.js -url="https://abs.twimg.com/responsive-web/client-web-legacy/i18n/it.b4ef1905.js" --o ja.js -url="https://abs.twimg.com/responsive-web/client-web-legacy/i18n/ja.02cba645.js" --o kn.js -url="https://abs.twimg.com/responsive-web/client-web-legacy/i18n/kn.4a4a19d5.js" --o ko.js -url="https://abs.twimg.com/responsive-web/client-web-legacy/i18n/ko.035bc5f5.js" --o mr.js -url="https://abs.twimg.com/responsive-web/client-web-legacy/i18n/mr.dd1e6525.js" --o ms.js -url="https://abs.twimg.com/responsive-web/client-web-legacy/i18n/ms.09e3cda5.js" --o nb.js -url="https://abs.twimg.com/responsive-web/client-web-legacy/i18n/nb.93d0cc35.js" --o nl.js -url="https://abs.twimg.com/responsive-web/client-web-legacy/i18n/nl.5c685cd5.js" --o pl.js -url="https://abs.twimg.com/responsive-web/client-web-legacy/i18n/pl.a6334e55.js" --o pt.js -url="https://abs.twimg.com/responsive-web/client-web-legacy/i18n/pt.6a60ed15.js" --o ro.js -url="https://abs.twimg.com/responsive-web/client-web-legacy/i18n/ro.9ec76765.js" --o ru.js -url="https://abs.twimg.com/responsive-web/client-web-legacy/i18n/ru.87e79b75.js" --o sk.js -url="https://abs.twimg.com/responsive-web/client-web-legacy/i18n/sk.32050315.js" --o sr.js -url="https://abs.twimg.com/responsive-web/client-web-legacy/i18n/sr.b2ffc2b5.js" --o sv.js -url="https://abs.twimg.com/responsive-web/client-web-legacy/i18n/sv.8697e675.js" --o ta.js -url="https://abs.twimg.com/responsive-web/client-web-legacy/i18n/ta.0229dee5.js" --o th.js -url="https://abs.twimg.com/responsive-web/client-web-legacy/i18n/th.108876e5.js" --o tr.js -url="https://abs.twimg.com/responsive-web/client-web-legacy/i18n/tr.9b55cb65.js" --o uk.js -url="https://abs.twimg.com/responsive-web/client-web-legacy/i18n/uk.db582eb5.js" --o ur.js -url="https://abs.twimg.com/responsive-web/client-web-legacy/i18n/ur.db029885.js" --o vi.js -url="https://abs.twimg.com/responsive-web/client-web-legacy/i18n/vi.1048e915.js" --o zh-Hant.js -url="https://abs.twimg.com/responsive-web/client-web-legacy/i18n/zh-Hant.3a034945.js" --o zh.js -url="https://abs.twimg.com/responsive-web/client-web-legacy/i18n/zh.828d34c5.js" \ No newline at end of file diff --git a/tweak-new-twitter.user.js b/tweak-new-twitter.user.js index 8c72e36..4499fe4 100644 --- a/tweak-new-twitter.user.js +++ b/tweak-new-twitter.user.js @@ -651,7 +651,7 @@ const locales = { uk: { ADD_MUTED_WORD: 'Додати слово до списку ігнорування', DISCOVER_MORE: 'Дізнавайтеся більше', - FOLLOWING: 'Читає(те)', + FOLLOWING: 'Стрічка', HOME: 'Головна', MUTE_THIS_CONVERSATION: 'Ігнорувати цю розмову', QUOTE_TWEET: 'Цитувати твіт',