Skip to content

Commit

Permalink
Merge pull request #4359 from wordpress-mobile/add/jetpack-layout-gri…
Browse files Browse the repository at this point in the history
…d-translations

Add Jetpack and Layout Grid translations
  • Loading branch information
fluiddot authored Dec 27, 2021
2 parents ad7fbc6 + 25ca1da commit cc93862
Show file tree
Hide file tree
Showing 110 changed files with 6,779 additions and 24 deletions.
1 change: 1 addition & 0 deletions RELEASE-NOTES.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
Unreleased
---
* [*] Give multi-line block names central alignment in inserter [https://github.com/wordpress-mobile/gutenberg-mobile/pull/4343]
* [**] Add Jetpack and Layout Grid translations [https://github.com/wordpress-mobile/gutenberg-mobile/pull/4359]

1.68.0
---
Expand Down
17 changes: 10 additions & 7 deletions bin/po2android.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,12 @@ const getUniqueName = ( function() {
};
}() );

function po2Android( poInput ) {
const po = gettextParser.po.parse( poInput );
const translations = po.translations[ '' ];
function po2Android( potFilesContent ) {
const translations = potFilesContent.reduce( (result, content) => {
const po = gettextParser.po.parse( content );
return { ...result, ...po.translations[ '' ] };
}, {});

const androidResourcesMap = Object.values( translations ).reduce( ( result, translation ) => {
if ( ! translation.msgid ) {
return result;
Expand Down Expand Up @@ -117,10 +120,10 @@ ${ indent }</string-array>

if ( require.main === module ) {
if ( process.stdin.isTTY ) {
const potFileName = process.argv[ 2 ];
const destination = process.argv[ 3 ];
const potFileContent = fs.readFileSync( potFileName );
const xmlOutput = po2Android( potFileContent, process.argv[ 3 ] );
const destination = process.argv[ 2 ];
const potFiles = process.argv.slice( 3 );
const potFilesContent = potFiles.map( (file) => fs.readFileSync( file ) );
const xmlOutput = po2Android( potFilesContent );
fs.writeFileSync( destination, xmlOutput );
} else {
let inputData = '';
Expand Down
17 changes: 10 additions & 7 deletions bin/po2swift.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@
const gettextParser = require( 'gettext-parser' ),
fs = require( 'fs' );

function po2Swift( poInput ) {
const po = gettextParser.po.parse( poInput );
const translations = po.translations[ '' ];
function po2Swift( potFilesContent ) {
const translations = potFilesContent.reduce( (result, content) => {
const po = gettextParser.po.parse( content );
return { ...result, ...po.translations[ '' ] };
}, {});

const swiftStringsMap = Object.values( translations ).reduce( ( result, translation ) => {
if ( ! translation.msgid ) {
return result;
Expand All @@ -23,10 +26,10 @@ function po2Swift( poInput ) {

if ( require.main === module ) {
if ( process.stdin.isTTY ) {
const potFileName = process.argv[ 2 ];
const destination = process.argv[ 3 ];
const potFileContent = fs.readFileSync( potFileName );
const swiftOutput = po2Swift( potFileContent, process.argv[ 3 ] );
const destination = process.argv[ 2 ];
const potFiles = process.argv.slice( 3 );
const potFilesContent = potFiles.map( (file) => fs.readFileSync( file ) );
const swiftOutput = po2Swift( potFilesContent );
fs.writeFileSync( destination, swiftOutput );
} else {
let inputData = '';
Expand Down
6 changes: 6 additions & 0 deletions bundle/android/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
<string name="gutenberg_native_add_link_text" tools:ignore="UnusedResources">Add link text</string>
<!-- translators: %s: social link name e.g: "Instagram". -->
<string name="gutenberg_native_add_link_to_s" tools:ignore="UnusedResources">Add link to %s</string>
<string name="gutenberg_native_add_media" tools:ignore="UnusedResources">ADD MEDIA</string>
<string name="gutenberg_native_add_paragraph_block" tools:ignore="UnusedResources">Add paragraph block</string>
<string name="gutenberg_native_add_this_email_link" tools:ignore="UnusedResources">Add this email link</string>
<string name="gutenberg_native_add_this_link" tools:ignore="UnusedResources">Add this link</string>
Expand All @@ -30,6 +31,7 @@
<string name="gutenberg_native_add_to_end" tools:ignore="UnusedResources">Add To End</string>
<string name="gutenberg_native_add_url" tools:ignore="UnusedResources">Add URL</string>
<string name="gutenberg_native_add_video" tools:ignore="UnusedResources">ADD VIDEO</string>
<string name="gutenberg_native_address_settings" tools:ignore="UnusedResources">Address Settings</string>
<string name="gutenberg_native_alt_text" tools:ignore="UnusedResources">Alt Text</string>
<string name="gutenberg_native_alternatively_you_can_detach_and_edit_these_blocks_separately_by" tools:ignore="UnusedResources">Alternatively, you can detach and edit these blocks separately by tapping \"Convert to regular blocks\".</string>
<string name="gutenberg_native_an_unknown_error_occurred_please_try_again" tools:ignore="UnusedResources">An unknown error occurred. Please try again.</string>
Expand Down Expand Up @@ -61,6 +63,7 @@
<string name="gutenberg_native_build_layouts" tools:ignore="UnusedResources">Build layouts</string>
<string name="gutenberg_native_button_link_url" tools:ignore="UnusedResources">Button Link URL</string>
<string name="gutenberg_native_button_position" tools:ignore="UnusedResources">Button position</string>
<string name="gutenberg_native_cancel" tools:ignore="UnusedResources">Cancel</string>
<string name="gutenberg_native_cancel_search" tools:ignore="UnusedResources">Cancel search</string>
<string name="gutenberg_native_change_block_position" tools:ignore="UnusedResources">Change block position</string>
<string name="gutenberg_native_changes_to_featured_image_will_not_be_affected_by_the_undo_redo_b" tools:ignore="UnusedResources">Changes to featured image will not be affected by the undo/redo buttons.</string>
Expand All @@ -75,6 +78,7 @@
<string name="gutenberg_native_clear_search" tools:ignore="UnusedResources">Clear search</string>
<!-- translators: %d: column index. -->
<string name="gutenberg_native_column_d" tools:ignore="UnusedResources">Column %d</string>
<string name="gutenberg_native_column_settings" tools:ignore="UnusedResources">Column Settings</string>
<string name="gutenberg_native_columns_settings" tools:ignore="UnusedResources">Columns Settings</string>
<string name="gutenberg_native_contact_support" tools:ignore="UnusedResources">Contact support</string>
<string name="gutenberg_native_convert_to_link" tools:ignore="UnusedResources">Convert to link</string>
Expand Down Expand Up @@ -227,6 +231,7 @@ translators: %s: Select control button label e.g. "Button width" -->
<string name="gutenberg_native_no_custom_placeholder_set" tools:ignore="UnusedResources">No custom placeholder set</string>
<string name="gutenberg_native_no_preview_available" tools:ignore="UnusedResources">No preview available</string>
<string name="gutenberg_native_note_column_layout_may_vary_between_themes_and_screen_sizes" tools:ignore="UnusedResources">Note: Column layout may vary between themes and screen sizes</string>
<string name="gutenberg_native_note_layout_may_vary_between_themes_and_screen_sizes" tools:ignore="UnusedResources">Note: Layout may vary between themes and screen sizes</string>
<string name="gutenberg_native_number_of_columns" tools:ignore="UnusedResources">Number of columns</string>
<string name="gutenberg_native_once_you_become_familiar_with_the_names_of_different_blocks_you_c" tools:ignore="UnusedResources">Once you become familiar with the names of different blocks, you can add a block by typing a forward slash followed by the block name — for example, /image or /heading.</string>
<string name="gutenberg_native_only_show_excerpt" tools:ignore="UnusedResources">Only show excerpt</string>
Expand All @@ -235,6 +240,7 @@ translators: %s: Select control button label e.g. "Button width" -->
<string name="gutenberg_native_open_link_in_a_browser" tools:ignore="UnusedResources">Open link in a browser</string>
<string name="gutenberg_native_open_settings" tools:ignore="UnusedResources">Open Settings</string>
<string name="gutenberg_native_outside" tools:ignore="UnusedResources">Outside</string>
<string name="gutenberg_native_padding" tools:ignore="UnusedResources">Padding</string>
<!-- translators: accessibility text. %s: Page break text. -->
<string name="gutenberg_native_page_break_block_s" tools:ignore="UnusedResources">Page break block. %s</string>
<!-- translators: accessibility text. empty page title. -->
Expand Down
6 changes: 6 additions & 0 deletions bundle/ios/GutenbergNativeTranslations.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ private func dummy() {
_ = NSLocalizedString("ADD LINK", comment: "")
_ = NSLocalizedString("Add link text", comment: "")
_ = NSLocalizedString("Add link to %s", comment: "translators: %s: social link name e.g: \"Instagram\".")
_ = NSLocalizedString("ADD MEDIA", comment: "")
_ = NSLocalizedString("Add paragraph block", comment: "")
_ = NSLocalizedString("Add this email link", comment: "")
_ = NSLocalizedString("Add this link", comment: "")
Expand All @@ -40,6 +41,7 @@ private func dummy() {
_ = NSLocalizedString("Add To End", comment: "")
_ = NSLocalizedString("Add URL", comment: "")
_ = NSLocalizedString("ADD VIDEO", comment: "")
_ = NSLocalizedString("Address Settings", comment: "")
_ = NSLocalizedString("Alt Text", comment: "")
_ = NSLocalizedString("Alternatively, you can detach and edit these blocks separately by tapping \"Convert to regular blocks\".", comment: "")
_ = NSLocalizedString("An unknown error occurred. Please try again.", comment: "")
Expand All @@ -63,6 +65,7 @@ private func dummy() {
_ = NSLocalizedString("Build layouts", comment: "")
_ = NSLocalizedString("Button Link URL", comment: "")
_ = NSLocalizedString("Button position", comment: "")
_ = NSLocalizedString("Cancel", comment: "")
_ = NSLocalizedString("Cancel search", comment: "")
_ = NSLocalizedString("Change block position", comment: "")
_ = NSLocalizedString("Changes to featured image will not be affected by the undo/redo buttons.", comment: "")
Expand All @@ -76,6 +79,7 @@ private func dummy() {
_ = NSLocalizedString("Choose video", comment: "")
_ = NSLocalizedString("Clear search", comment: "")
_ = NSLocalizedString("Column %d", comment: "translators: %d: column index.")
_ = NSLocalizedString("Column Settings", comment: "")
_ = NSLocalizedString("Columns Settings", comment: "")
_ = NSLocalizedString("Contact support", comment: "")
_ = NSLocalizedString("Convert to link", comment: "")
Expand Down Expand Up @@ -210,6 +214,7 @@ private func dummy() {
_ = NSLocalizedString("No custom placeholder set", comment: "")
_ = NSLocalizedString("No preview available", comment: "")
_ = NSLocalizedString("Note: Column layout may vary between themes and screen sizes", comment: "")
_ = NSLocalizedString("Note: Layout may vary between themes and screen sizes", comment: "")
_ = NSLocalizedString("Number of columns", comment: "")
_ = NSLocalizedString("Once you become familiar with the names of different blocks, you can add a block by typing a forward slash followed by the block name — for example, /image or /heading.", comment: "")
_ = NSLocalizedString("Only show excerpt", comment: "")
Expand All @@ -218,6 +223,7 @@ private func dummy() {
_ = NSLocalizedString("Open link in a browser", comment: "")
_ = NSLocalizedString("Open Settings", comment: "")
_ = NSLocalizedString("Outside", comment: "")
_ = NSLocalizedString("Padding", comment: "")
_ = NSLocalizedString("Page break block. %s", comment: "translators: accessibility text. %s: Page break text.")
_ = NSLocalizedString("Page title. %s", comment: "translators: accessibility text. %s: text content of the page title.")
_ = NSLocalizedString("Page title. Empty", comment: "translators: accessibility text. empty page title.")
Expand Down
16 changes: 11 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,21 @@
"update:wpcli": "bin/wp-cli.phar cli update --nightly --yes && bin/wp-cli.phar --info",
"prewp": "npm run install:wpcli && npm run update:wpcli",
"wp": "php -d memory_limit=4G bin/wp-cli.phar",
"makepot:android": "npm run wp -- i18n make-pot ./gutenberg/packages --include=*.native.js,*.android.js --exclude=test/*,e2e-tests/*,build/*,build-module/*,build-style/* --skip-php --subtract=./gutenberg.pot --ignore-domain gutenberg-android.pot",
"makepot:ios": "npm run wp -- i18n make-pot ./gutenberg/packages --include=*.native.js,*.ios.js --exclude=test/*,e2e-tests/*,build/*,build-module/*,build-style/* --skip-php --subtract=./gutenberg.pot --ignore-domain gutenberg-ios.pot",
"makepot:android:gutenberg": "npm run wp -- i18n make-pot ./gutenberg/packages --include=*.native.js,*.android.js --exclude=test/*,e2e-tests/*,build/*,build-module/*,build-style/* --skip-php --subtract=./gutenberg.pot --ignore-domain gutenberg-android.pot",
"makepot:android:jetpack": "npm run wp -- i18n make-pot ./jetpack/projects/plugins/jetpack/extensions --include=*.native.js,*.android.js --exclude=test/*,e2e-tests/*,build/*,build-module/*,build-style/* --skip-php --subtract=./jetpack.pot --ignore-domain jetpack-android.pot",
"makepot:android:layout-grid": "npm run wp -- i18n make-pot ./block-experiments/blocks/layout-grid --include=*.native.js,*.android.js --exclude=test/*,e2e-tests/*,build/*,build-module/*,build-style/* --skip-php --subtract=./layout-grid.pot --ignore-domain layout-grid-android.pot",
"makepot:ios:gutenberg": "npm run wp -- i18n make-pot ./gutenberg/packages --include=*.native.js,*.ios.js --exclude=test/*,e2e-tests/*,build/*,build-module/*,build-style/* --skip-php --subtract=./gutenberg.pot --ignore-domain gutenberg-ios.pot",
"makepot:ios:jetpack": "npm run wp -- i18n make-pot ./jetpack/projects/plugins/jetpack/extensions --include=*.native.js,*.ios.js --exclude=test/*,e2e-tests/*,build/*,build-module/*,build-style/* --skip-php --subtract=./jetpack.pot --ignore-domain jetpack-ios.pot",
"makepot:ios:layout-grid": "npm run wp -- i18n make-pot ./block-experiments/blocks/layout-grid --include=*.native.js,*.ios.js --exclude=test/*,e2e-tests/*,build/*,build-module/*,build-style/* --skip-php --subtract=./layout-grid.pot --ignore-domain layout-grid-ios.pot",
"premakepot:gutenberg": "npm run clean:gutenberg && npm run build:gutenberg",
"makepot:gutenberg": "npm run wp -- i18n make-pot ./gutenberg/packages --exclude=test/*,e2e-tests/*,build/*,build-module/*,build-style/*,*.native.js,*.ios.js,*.android.js,bundle/* --ignore-domain gutenberg.pot",
"postmakepot:gutenberg": "npm run clean:gutenberg",
"pregenstrings": "npm run makepot:gutenberg",
"makepot:jetpack": "npm run wp -- i18n make-pot ./jetpack/projects/plugins/jetpack/extensions --exclude=test/*,e2e-tests/*,build/*,build-module/*,build-style/*,*.native.js,*.ios.js,*.android.js,bundle/* --ignore-domain jetpack.pot",
"makepot:layout-grid": "npm run wp -- i18n make-pot ./block-experiments/blocks/layout-grid --exclude=test/*,e2e-tests/*,build/*,build-module/*,build-style/*,*.native.js,*.ios.js,*.android.js,bundle/* --ignore-domain layout-grid.pot",
"pregenstrings": "npm run makepot:gutenberg && npm run makepot:jetpack && npm run makepot:layout-grid",
"genstrings": "npm run genstrings:android && npm run genstrings:ios",
"genstrings:android": "npm run makepot:android && ./bin/po2android.js gutenberg-android.pot bundle/android/strings.xml",
"genstrings:ios": "npm run makepot:ios && ./bin/po2swift.js gutenberg-ios.pot bundle/ios/GutenbergNativeTranslations.swift",
"genstrings:android": "npm run makepot:android:gutenberg && npm run makepot:android:jetpack && npm run makepot:android:layout-grid && ./bin/po2android.js bundle/android/strings.xml gutenberg-android.pot jetpack-android.pot layout-grid-android.pot",
"genstrings:ios": "npm run makepot:ios:gutenberg && npm run makepot:ios:jetpack && npm run makepot:ios:layout-grid && ./bin/po2swift.js bundle/ios/GutenbergNativeTranslations.swift gutenberg-ios.pot jetpack-ios.pot layout-grid-ios.pot",
"prewpandroid": "rm -Rf $TMPDIR/gbmobile-wpandroidfakernroot && mkdir $TMPDIR/gbmobile-wpandroidfakernroot && ln -s $(cd \"$(dirname \"../../../\")\"; pwd) $TMPDIR/gbmobile-wpandroidfakernroot/android",
"wpandroid": "cd gutenberg && react-native run-android --root $TMPDIR/gbmobile-wpandroidfakernroot --variant wasabiDebug --appIdSuffix beta --appFolder WordPress --main-activity=ui.WPLaunchActivity",
"test": "cross-env NODE_ENV=test jest --verbose --config ./jest.config.js",
Expand Down
19 changes: 18 additions & 1 deletion src/block-experiments-setup.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,25 @@
/**
* Internal dependencies
*/
// This file is to set up the jetpack/layout-grid block that currently lives in block-experiments/blocks/layout-grid
import { registerBlock } from '../block-experiments/blocks/layout-grid/src';
import setupLocale from './setup-locale';
import { getTranslation as getLayoutGridTranslation } from './i18n-translations/layout-grid';

export default function setupBlockExperiments( capabilities ) {
const LAYOUT_GRID_LOCALE_DOMAIN = 'layout-grid';

export function setupBlockExperiments( capabilities ) {
if ( capabilities.layoutGridBlock ) {
registerBlock();
}
}

export function setupBlockExperimentsLocale( locale, extraTranslations ) {
// Setup locale for Layout Grid
setupLocale( {
domain: LAYOUT_GRID_LOCALE_DOMAIN,
locale,
extraTranslations,
getTranslation: getLayoutGridTranslation,
} );
}
130 changes: 130 additions & 0 deletions src/i18n-translations/jetpack/data/ar.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
{
"Embed a SmartFrame Image.": [],
"smartframe": [],
"Embed an Instagram post.": [
"تضمين منشور Instagram."
],
"Embed a Facebook post.": [
"تضمين منشور فيس بوك."
],
"Embed a Loom video.": [
"قم بتضمين فيديو Loom."
],
"video": [
"فيديو"
],
"Add an interactive story.": [
"أضف قصة تفاعلية."
],
"block search term\u0004video": [
"فيديو"
],
"block search term\u0004story": [
"قصة"
],
"Story": [
"قصة"
],
"Grow": [
"تنمية"
],
"Earn": [
"تحقيق ربح"
],
"block search term\u0004social": [
"اجتماعي"
],
"block search term\u0004address": [
"عنوان"
],
"block search term\u0004phone": [
"هاتف"
],
"block search term\u0004message": [
"رسالة"
],
"block search term\u0004image": [
"صورة"
],
"Lets you add an email address with an automatically generated click-to-email link.": [
"يسمح لك بإضافة عنوان بريد إلكتروني من خلال رابط \"انقر للاتصال\" الذي تم إنشاؤه تلقائيًّا."
],
"Open address in Google Maps": [
"فتح عنوان في Google Maps"
],
"block search term\u0004gallery": [
"معرض"
],
"block search term\u0004cell": [
"خلية"
],
"block search term\u0004telephone": [
"هاتف أرضي"
],
"block search term\u0004mobile": [
"هاتف محمول"
],
"block search term\u0004email": [
"البريد الإلكتروني"
],
"block search term\u0004place": [
"مكان"
],
"block search term\u0004direction": [
"الاتجاه"
],
"block search term\u0004location": [
"الموقع"
],
"Lets you add a phone number with an automatically generated click-to-call link.": [
"يسمح لك بإضافة رقم هاتف مع رابط \"أنقر للاتصال\" الذي يتم إنشاؤه تلقائيًّا."
],
"Phone Number": [
"رقم الهاتف"
],
"Phone number": [
"رقم الهاتف"
],
"Lets you add an email address, phone number, and physical address with improved markup for better SEO results.": [
"يسمح لك بإضافة عنوان بريد إلكتروني ورقم هاتف وعنوان فعلي مع لغة تمييز مُحسّنة للحصول على أفضل نتائج تحسين محركات البحث."
],
"Lets you add a physical address with Schema markup.": [
"يسمح لك بإضافة عنوان فعلي مع تمييز المخطط."
],
"Address": [
"العنوان"
],
"Country": [
"البلد"
],
"Postal/Zip Code": [
"الرمز البريدي/رمز Zip"
],
"State/Province/Region": [
"الولاية/المقاطعة/الإقليم"
],
"City": [
"المدينة"
],
"Address Line 3": [
"سطر العنوان 3"
],
"Address Line 2": [
"سطر العنوان 2"
],
"Street Address": [
"عنوان الشارع"
],
"Link address to Google Maps": [
"ربط العنوان بـ Google Maps"
],
"Contact Info": [
"معلومات الإتصال"
],
"Email Address": [
"عنوان البريد الإلكتروني"
],
"Email": [
"البريد الإلكتروني"
]
}
Loading

0 comments on commit cc93862

Please sign in to comment.