diff --git a/.github/workflows/check-translations.yml b/.github/workflows/check-translations.yml new file mode 100644 index 00000000000..ea60a8f3722 --- /dev/null +++ b/.github/workflows/check-translations.yml @@ -0,0 +1,65 @@ +name: Check Missing Translations +on: + pull_request: + types: [opened, labeled, unlabeled, synchronize] + paths: + - '**/Localizable.strings' # Only run this check if localized string files have changed, exclude non-payments projects. + - '!StripeFinancialConnections/**' + - '!StripeIdentity/**' + - '!StripeConnections/**' + +jobs: + check-translations: + runs-on: ubuntu-latest + permissions: + pull-requests: write + + steps: + - name: Checkout code + uses: actions/checkout@v1 + with: + fetch-depth: 0 + - name: Set up Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: 3.0 + - name: Install dependencies + run: gem install net-http net-uri json + - name: Run translation check script + env: + LOKALISE_API_KEY: ${{ secrets.LOKALISE_API_KEY_READONLY }} + run: ruby ci_scripts/check_for_untranslated_strings.rb + - name: Read missing translations + id: missing + run: echo "::set-output name=translations::$( 30 + puts "Translations for '#{str}' exists." + else + puts "Translations for '#{str}' do not exist." + missing_translations << str + end + else + puts "String '#{str}' does not exist. Make sure you have uploaded your strings to Lokalise." + missing_translations << str + end + end + end + + missing_translations +end + +new_strings_added = get_added_strings($ROOT_DIR) +missing_translations = check_lokalise_translations(ENV['LOKALISE_API_KEY'], '747824695e51bc2f4aa912.89576472', new_strings_added) +puts(missing_translations) +if missing_translations.any? + File.open("missing_translations.txt", 'w') { |f| f.write missing_translations.join(", ") } +end