From 5c4e46e16b283539870439973f437e11bc66a4ad Mon Sep 17 00:00:00 2001 From: tomharrigan Date: Mon, 24 Jul 2017 14:44:55 -0400 Subject: [PATCH 1/8] add domain path --- voicewp.php | 1 + 1 file changed, 1 insertion(+) diff --git a/voicewp.php b/voicewp.php index 0c9ec1c..d2a36f2 100644 --- a/voicewp.php +++ b/voicewp.php @@ -7,6 +7,7 @@ * Author URI: https://voicewp.com * Version: 1.0.0 * Text Domain: voicewp + * Domain Path: /inc/lang * License: MIT */ From db79d54eaef5ff3f900a0a0d7045b5f6039c34c0 Mon Sep 17 00:00:00 2001 From: tomharrigan Date: Mon, 24 Jul 2017 14:45:39 -0400 Subject: [PATCH 2/8] generate pot file --- inc/lang/voicewp.pot | 461 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 461 insertions(+) create mode 100644 inc/lang/voicewp.pot diff --git a/inc/lang/voicewp.pot b/inc/lang/voicewp.pot new file mode 100644 index 0000000..7007e31 --- /dev/null +++ b/inc/lang/voicewp.pot @@ -0,0 +1,461 @@ +#, fuzzy +msgid "" +msgstr "" +"Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n" +"Project-Id-Version: VoiceWP\n" +"POT-Creation-Date: 2017-07-24 14:44-0400\n" +"PO-Revision-Date: 2017-07-24 14:42-0400\n" +"Last-Translator: \n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"X-Generator: Poedit 2.0.3\n" +"X-Poedit-Basepath: ../..\n" +"X-Poedit-Flags-xgettext: --add-comments=translators:\n" +"X-Poedit-WPHeader: voicewp.php\n" +"X-Poedit-SourceCharset: UTF-8\n" +"X-Poedit-KeywordsList: __;_e;_n:1,2;_x:1,2c;_ex:1,2c;_nx:4c,1,2;esc_attr__;" +"esc_attr_e;esc_attr_x:1,2c;esc_html__;esc_html_e;esc_html_x:1,2c;_n_noop:1,2;" +"_nx_noop:3c,1,2;__ngettext_noop:1,2\n" +"X-Poedit-SearchPath-0: .\n" +"X-Poedit-SearchPathExcluded-0: *.js\n" + +#: alexa/request/application.php:33 +msgid "Application Id not matched" +msgstr "" + +#: alexa/request/certificate.php:101 +msgid "Request timestamp was too old. Possible replay attack." +msgstr "" + +#: alexa/request/certificate.php:114 +msgid "" +"The remote certificate doesn't contain a valid SANs in the signature or is " +"expired." +msgstr "" + +#: alexa/request/certificate.php:129 +msgid "Request signature could not be verified" +msgstr "" + +#: alexa/request/certificate.php:167 +msgid "Protocol isn't secure. Request isn't from Alexa." +msgstr "" + +#: alexa/request/certificate.php:169 +msgid "Certificate isn't from Amazon. Request isn't from Alexa." +msgstr "" + +#: alexa/request/certificate.php:171 +#, php-format +msgid "Certificate isn't in '%s' folder. Request isn't from Alexa." +msgstr "" + +#: alexa/request/certificate.php:173 +#, php-format +msgid "Port isn't %s. Request isn't from Alexa." +msgstr "" + +#: alexa/request/request.php:31 +msgid "Alexa Request requires the raw JSON data to validate request signature" +msgstr "" + +#: alexa/request/request.php:92 +#, php-format +msgid "Unknown request type: %s" +msgstr "" + +#. translators: %s: site title +#: alexa/skill/news.php:91 +#, php-format +msgid "Latest from %s" +msgstr "" + +#: alexa/skill/news.php:214 +msgid "" +"Sorry! I couldn't find any news about that topic. Try asking something else!" +msgstr "" + +#: inc/class-voicewp.php:40 +msgid "To test your skill, use an Alexa enabled device or Echosim.io" +msgstr "" + +#: inc/class-voicewp.php:97 +msgid "Request body is empty" +msgstr "" + +#. translators: 1: minimum WordPress version, 2: current WordPress version +#: inc/compat.php:28 +#, php-format +msgid "" +"VoiceWP requires at least WordPress version %1$s. You are currently running " +"version %2$s." +msgstr "" + +#: inc/compat.php:36 +msgid "VoiceWP requires the WordPress REST API." +msgstr "" + +#: inc/compat.php:40 +msgid "VoiceWP requires the WordPress Fieldmanager plugin." +msgstr "" + +#. translators: 1: minimum Fieldmanager version, 2: current Fieldmanager version +#: inc/compat.php:48 +#, php-format +msgid "" +"VoiceWP requires at least Fieldmanager version %1$s. You are currently " +"running version %2$s." +msgstr "" + +#: inc/fields.php:11 +msgid "Skill Type" +msgstr "" + +#: inc/fields.php:16 inc/fields.php:203 +msgid "Fact / Quote" +msgstr "" + +#: inc/fields.php:18 +msgid "What type of functionality is being added?" +msgstr "" + +#: inc/fields.php:20 +msgid "Default App Card Image" +msgstr "" + +#: inc/fields.php:22 +msgid "" +"Image to be used when no other is provided. App cards can be displayed " +"within the Alexa app when she responds to a user request." +msgstr "" + +#: inc/fields.php:26 +msgid "This is a standalone skill" +msgstr "" + +#: inc/fields.php:27 +msgid "Will this be its own skill or is this part of another skill?" +msgstr "" + +#: inc/fields.php:29 +msgid "Alexa Application ID" +msgstr "" + +#: inc/fields.php:31 inc/fields.php:262 +msgid "Add the application ID given by Amazon" +msgstr "" + +#: inc/fields.php:42 +msgid "" +"This is the endpoint URL of your skill. Paste this within the configuration " +"tab for your skill in the developer portal." +msgstr "" + +#: inc/fields.php:63 +msgid "Skill Settings" +msgstr "" + +#: inc/fields.php:78 +msgid "Source" +msgstr "" + +#: inc/fields.php:88 inc/fields.php:101 +msgid "Text" +msgstr "" + +#: inc/fields.php:89 inc/fields.php:112 +msgid "HTTPS URL to an MP3" +msgstr "" + +#: inc/fields.php:90 inc/fields.php:128 +msgid "Uploaded MP3" +msgstr "" + +#: inc/fields.php:102 +msgid "Text should be under 4,500 characters." +msgstr "" + +#: inc/fields.php:130 inc/fields.php:132 +msgid "Select a File" +msgstr "" + +#: inc/fields.php:131 +msgid "Select File" +msgstr "" + +#: inc/fields.php:166 +msgid "Please make sure this is a URL to an MP3 file." +msgstr "" + +#: inc/fields.php:176 +msgid "Please make sure this is an MP3 upload." +msgstr "" + +#: inc/fields.php:180 +msgid "Audio should be under 10 minutes long." +msgstr "" + +#: inc/fields.php:188 +msgid "Briefing Content" +msgstr "" + +#: inc/fields.php:200 +msgid "Add another fact or quote" +msgstr "" + +#: inc/fields.php:204 +msgid "Add a fact or quote" +msgstr "" + +#: inc/fields.php:207 +msgid "Attribution" +msgstr "" + +#: inc/fields.php:208 +msgid "Add attribution if applicable" +msgstr "" + +#: inc/fields.php:211 +msgid "Alexa App Card Image" +msgstr "" + +#: inc/fields.php:215 +msgid "Facts / Quotes" +msgstr "" + +#: inc/fields.php:236 +msgid "Skill name" +msgstr "" + +#: inc/fields.php:237 +msgid "Optional name of skill. If empty, site name will be used instead." +msgstr "" + +#: inc/fields.php:243 +msgid "Welcome message" +msgstr "" + +#: inc/fields.php:244 +msgid "" +"This is the message a person hears when they open your skill with an " +"utterance such as \"Alexa, open {your skill name}\"" +msgstr "" + +#: inc/fields.php:245 +msgid "" +"Welcome to the {put your skill name here} Skill. This skill allows you to " +"listen to content from {your site name}. You can ask questions like: What " +"are the latest articles? ... Now, what can I help you with." +msgstr "" + +#: inc/fields.php:249 +msgid "Help message" +msgstr "" + +#: inc/fields.php:250 +msgid "This is the message a person hears when they ask your skill for 'help'" +msgstr "" + +#: inc/fields.php:251 +msgid "" +"{put your skill name here} provides you with the latest content from {your " +"site name}. You can ask me for the latest articles, and then select an item " +"from the list by saying, for example, 'read the 3rd article' Or you can also " +"say exit... What can I help you with?" +msgstr "" + +#: inc/fields.php:255 +msgid "Stop message" +msgstr "" + +#: inc/fields.php:256 +msgid "" +"You can optionally provide a message when a person is done with your skill." +msgstr "" + +#: inc/fields.php:257 +msgid "Thanks for listening!" +msgstr "" + +#: inc/fields.php:261 +msgid "News skill ID" +msgstr "" + +#: inc/fields.php:268 +msgid "Allow people to ask for content from specific:" +msgstr "" + +#: inc/fields.php:274 +msgid "Word Pronunciation Substitutions" +msgstr "" + +#: inc/fields.php:276 +msgid "" +"This allows you to define a global dictionary of words, phrases, " +"abbreviations that Alexa should pronounce a certain way. For example, " +"perhaps every occurrance of the state abreviation 'TN' should be pronounced " +"as 'Tennessee', or 'NYC should be read as 'New York City' or the chemical " +"'Mg' read as 'Magnesium'. " +msgstr "" + +#: inc/fields.php:282 +msgid "Phrase / Word / Abbreviation" +msgstr "" + +#: inc/fields.php:284 +msgid "Add another phrase, word, or abbreviation" +msgstr "" + +#: inc/fields.php:288 +msgid "Phrase to pronounce differently" +msgstr "" + +#: inc/fields.php:294 +msgid "How the above phrase should be pronounced." +msgstr "" + +#: inc/fields.php:307 +msgid "" +"The Intent Schema for your News skill. Add this to your news skill in the Amazon developer " +"console." +msgstr "" + +#: inc/fields.php:318 +msgid "Custom Slot Types" +msgstr "" + +#: inc/fields.php:322 +msgid "" +"These slot types must be added to your news skill in the Amazon developer " +"portal." +msgstr "" + +#: inc/fields.php:324 inc/fields.php:340 +msgid "Type" +msgstr "" + +#: inc/fields.php:332 inc/fields.php:348 +msgid "Values" +msgstr "" + +#: inc/fields.php:374 +msgid "" +"Here's a starting point for your skill's Sample Utterances. You can add " +"these to your news skill in the Amazon developer console." +msgstr "" + +#: inc/fields.php:385 +msgid "Interaction Model" +msgstr "" + +#: inc/fields.php:398 +msgid "Alexa Skill Settings" +msgstr "" + +#: post-types/class-voicewp-post-type-briefing.php:26 +#: post-types/class-voicewp-post-type-briefing.php:37 +msgid "Briefings" +msgstr "" + +#: post-types/class-voicewp-post-type-briefing.php:27 +msgid "Briefing" +msgstr "" + +#: post-types/class-voicewp-post-type-briefing.php:28 +#: post-types/class-voicewp-post-type-briefing.php:29 +msgid "Add New Briefing" +msgstr "" + +#: post-types/class-voicewp-post-type-briefing.php:30 +msgid "Edit Briefing" +msgstr "" + +#: post-types/class-voicewp-post-type-briefing.php:31 +msgid "New Briefing" +msgstr "" + +#: post-types/class-voicewp-post-type-briefing.php:32 +msgid "View Briefing" +msgstr "" + +#: post-types/class-voicewp-post-type-briefing.php:33 +msgid "Search Briefing" +msgstr "" + +#: post-types/class-voicewp-post-type-briefing.php:34 +msgid "No Briefings found" +msgstr "" + +#: post-types/class-voicewp-post-type-briefing.php:35 +msgid "No Briefings found in Trash" +msgstr "" + +#: post-types/class-voicewp-post-type-briefing.php:36 +msgid "Parent Briefing:" +msgstr "" + +#: post-types/class-voicewp-post-type-skill.php:35 +#: post-types/class-voicewp-post-type-skill.php:46 +msgid "Skills" +msgstr "" + +#: post-types/class-voicewp-post-type-skill.php:36 +msgid "Skill" +msgstr "" + +#: post-types/class-voicewp-post-type-skill.php:37 +#: post-types/class-voicewp-post-type-skill.php:38 +msgid "Add New Skill" +msgstr "" + +#: post-types/class-voicewp-post-type-skill.php:39 +msgid "Edit Skill" +msgstr "" + +#: post-types/class-voicewp-post-type-skill.php:40 +msgid "New Skill" +msgstr "" + +#: post-types/class-voicewp-post-type-skill.php:41 +msgid "View Skill" +msgstr "" + +#: post-types/class-voicewp-post-type-skill.php:42 +msgid "Search Skills" +msgstr "" + +#: post-types/class-voicewp-post-type-skill.php:43 +msgid "No Skills found" +msgstr "" + +#: post-types/class-voicewp-post-type-skill.php:44 +msgid "No Skills found in Trash" +msgstr "" + +#: post-types/class-voicewp-post-type-skill.php:45 +msgid "Parent Skill:" +msgstr "" + +#. Plugin Name of the plugin/theme +msgid "VoiceWP" +msgstr "" + +#. Plugin URI of the plugin/theme +msgid "https://github.com/tomharrigan/" +msgstr "" + +#. Description of the plugin/theme +msgid "Create Alexa skills using your WordPress site" +msgstr "" + +#. Author of the plugin/theme +msgid "TomHarrigan" +msgstr "" + +#. Author URI of the plugin/theme +msgid "https://voicewp.com" +msgstr "" From b8ddaf10f0b3989f4f83ab923c93af8ec973bfea Mon Sep 17 00:00:00 2001 From: tomharrigan Date: Mon, 31 Jul 2017 22:00:08 -0400 Subject: [PATCH 3/8] Allow utterances to be translated --- speechAssets/utterances.php | 143 ++++++++++++++++++++++++++++++++++++ 1 file changed, 143 insertions(+) create mode 100644 speechAssets/utterances.php diff --git a/speechAssets/utterances.php b/speechAssets/utterances.php new file mode 100644 index 0000000..45e60f6 --- /dev/null +++ b/speechAssets/utterances.php @@ -0,0 +1,143 @@ + array( + esc_html__( 'can I have the latest content', 'voicewp' ), + esc_html__( 'can I have the latest articles', 'voicewp' ), + esc_html__( 'can I have the latest stories', 'voicewp' ), + esc_html__( 'can I have the latest news', 'voicewp' ), + esc_html__( 'what is the latest content', 'voicewp' ), + esc_html__( 'what are the latest articles', 'voicewp' ), + esc_html__( 'what are the latest stories', 'voicewp' ), + esc_html__( 'what is the latest news', 'voicewp' ), + esc_html__( "what's the latest content", 'voicewp' ), + esc_html__( "what're the latest articles", 'voicewp' ), + esc_html__( "what're the latest stories", 'voicewp' ), + esc_html__( "what's the latest news", 'voicewp' ), + esc_html__( 'the latest content', 'voicewp' ), + esc_html__( 'the latest articles', 'voicewp' ), + esc_html__( 'the latest stories', 'voicewp' ), + esc_html__( 'the latest news', 'voicewp' ), + esc_html__( 'give me the latest content', 'voicewp' ), + esc_html__( 'give me the latest articles', 'voicewp' ), + esc_html__( 'give me the latest stories', 'voicewp' ), + esc_html__( 'give me the latest news', 'voicewp' ), + esc_html__( 'get the latest content', 'voicewp' ), + esc_html__( 'get the latest articles', 'voicewp' ), + esc_html__( 'get the latest stories', 'voicewp' ), + esc_html__( 'get the latest news', 'voicewp' ), + esc_html__( "what's up", 'voicewp' ), + esc_html__( "what's new", 'voicewp' ), + esc_html__( 'read the latest content', 'voicewp' ), + esc_html__( 'read the latest articles', 'voicewp' ), + esc_html__( 'read the latest stories', 'voicewp' ), + esc_html__( 'read the latest news', 'voicewp' ), + esc_html__( 'read me the latest content', 'voicewp' ), + esc_html__( 'read me the latest articles', 'voicewp' ), + esc_html__( 'read me the latest stories', 'voicewp' ), + esc_html__( 'read me the latest news', 'voicewp' ), + esc_html__( 'tell me the latest articles', 'voicewp' ), + esc_html__( 'tell me the latest stories', 'voicewp' ), + esc_html__( 'tell me the latest news', 'voicewp' ), + ), + 'LatestTerm' => array( + /* translators: %s: taxonomy term used in Alexa utterance for latest content */ + sprintf( esc_html__( 'the latest %s articles', 'voicewp' ), $term_name_slot ), + /* translators: %s: taxonomy term used in Alexa utterance for latest content */ + sprintf( esc_html__( 'the latest %s content', 'voicewp' ), $term_name_slot ), + /* translators: %s: taxonomy term used in Alexa utterance for latest content */ + sprintf( esc_html__( 'the latest %s news', 'voicewp' ), $term_name_slot ), + /* translators: %s: taxonomy term used in Alexa utterance for latest content */ + sprintf( esc_html__( 'the latest %s stories', 'voicewp' ), $term_name_slot ), + /* translators: %s: taxonomy term used in Alexa utterance for latest content */ + sprintf( esc_html__( '%s content', 'voicewp' ), $term_name_slot ), + /* translators: %s: taxonomy term used in Alexa utterance for latest content */ + sprintf( esc_html__( '%s articles', 'voicewp' ), $term_name_slot ), + /* translators: %s: taxonomy term used in Alexa utterance for latest content */ + sprintf( esc_html__( '%s stories', 'voicewp' ), $term_name_slot ), + /* translators: %s: taxonomy term used in Alexa utterance for latest content */ + sprintf( esc_html__( '%s news', 'voicewp' ), $term_name_slot ), + /* translators: %s: taxonomy term used in Alexa utterance for latest content */ + sprintf( esc_html__( 'Get the latest %s articles', 'voicewp' ), $term_name_slot ), + /* translators: %s: taxonomy term used in Alexa utterance for latest content */ + sprintf( esc_html__( 'Get the latest %s content', 'voicewp' ), $term_name_slot ), + /* translators: %s: taxonomy term used in Alexa utterance for latest content */ + sprintf( esc_html__( 'Get the latest %s news', 'voicewp' ), $term_name_slot ), + /* translators: %s: taxonomy term used in Alexa utterance for latest content */ + sprintf( esc_html__( 'Get the latest %s stories', 'voicewp' ), $term_name_slot ), + /* translators: %s: taxonomy term used in Alexa utterance for latest content */ + sprintf( esc_html__( 'Get %s articles', 'voicewp' ), $term_name_slot ), + /* translators: %s: taxonomy term used in Alexa utterance for latest content */ + sprintf( esc_html__( 'Get %s content', 'voicewp' ), $term_name_slot ), + /* translators: %s: taxonomy term used in Alexa utterance for latest content */ + sprintf( esc_html__( 'Get %s news', 'voicewp' ), $term_name_slot ), + /* translators: %s: taxonomy term used in Alexa utterance for latest content */ + sprintf( esc_html__( 'Get %s stories', 'voicewp' ), $term_name_slot ), + ), + 'ReadPost' => array( + /* translators: %s: number */ + sprintf( esc_html__( 'Read the %s', 'voicewp' ), $post_number_slot ), + /* translators: %s: number */ + sprintf( esc_html__( 'Read the %s post', 'voicewp' ), $post_number_slot ), + /* translators: %s: number */ + sprintf( esc_html__( 'Read the %s article', 'voicewp' ), $post_number_slot ), + /* translators: %s: number */ + sprintf( esc_html__( 'Read the %s story', 'voicewp' ), $post_number_slot ), + /* translators: %s: number */ + sprintf( esc_html__( 'Read %s', 'voicewp' ), $post_number_slot ), + /* translators: %s: number */ + sprintf( esc_html__( 'Read %s to me', 'voicewp' ), $post_number_slot ), + /* translators: %s: number */ + sprintf( esc_html__( 'Read me the %s', 'voicewp' ), $post_number_slot ), + /* translators: %s: number */ + sprintf( esc_html__( 'Read me the %s post', 'voicewp' ), $post_number_slot ), + /* translators: %s: number */ + sprintf( esc_html__( 'Read me the %s article', 'voicewp' ), $post_number_slot ), + /* translators: %s: number */ + sprintf( esc_html__( 'Read me the %s story', 'voicewp' ), $post_number_slot ), + /* translators: %s: number */ + sprintf( esc_html__( 'Read me %s', 'voicewp' ), $post_number_slot ), + /* translators: %s: ordinal number */ + sprintf( esc_html__( 'Read the %s', 'voicewp' ), $post_number_ordinal_slot ), + /* translators: %s: ordinal number */ + sprintf( esc_html__( 'Read the %s post', 'voicewp' ), $post_number_ordinal_slot ), + /* translators: %s: ordinal number */ + sprintf( esc_html__( 'Read the %s article', 'voicewp' ), $post_number_ordinal_slot ), + /* translators: %s: ordinal number */ + sprintf( esc_html__( 'Read the %s story', 'voicewp' ), $post_number_ordinal_slot ), + /* translators: %s: ordinal number */ + sprintf( esc_html__( 'Read %s', 'voicewp' ), $post_number_ordinal_slot ), + /* translators: %s: ordinal number */ + sprintf( esc_html__( 'Read me the %s', 'voicewp' ), $post_number_ordinal_slot ), + /* translators: %s: ordinal number */ + sprintf( esc_html__( 'Read me the %s post', 'voicewp' ), $post_number_ordinal_slot ), + /* translators: %s: ordinal number */ + sprintf( esc_html__( 'Read me the %s article', 'voicewp' ), $post_number_ordinal_slot ), + /* translators: %s: ordinal number */ + sprintf( esc_html__( 'Read me the %s story', 'voicewp' ), $post_number_ordinal_slot ), + /* translators: %s: ordinal number */ + sprintf( esc_html__( 'Read me %s', 'voicewp' ), $post_number_ordinal_slot ), + /* translators: %s: ordinal number */ + sprintf( esc_html__( 'Read the %s to me', 'voicewp' ), $post_number_ordinal_slot ), + /* translators: %s: ordinal number */ + sprintf( esc_html__( 'Read the %s post to me', 'voicewp' ), $post_number_ordinal_slot ), + /* translators: %s: ordinal number */ + sprintf( esc_html__( 'Read the %s article to me', 'voicewp' ), $post_number_ordinal_slot ), + /* translators: %s: ordinal number */ + sprintf( esc_html__( 'Read the %s story to me', 'voicewp' ), $post_number_ordinal_slot ), + /* translators: %s: ordinal number */ + sprintf( esc_html__( 'Read %s to me', 'voicewp' ), $post_number_ordinal_slot ), + ), +); From 59bb7f5ad49a2debfdf3b088fd55b35aafa620e7 Mon Sep 17 00:00:00 2001 From: tomharrigan Date: Mon, 31 Jul 2017 22:00:29 -0400 Subject: [PATCH 4/8] bring in utterances from php file --- inc/fields.php | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/inc/fields.php b/inc/fields.php index da1434d..da644dd 100644 --- a/inc/fields.php +++ b/inc/fields.php @@ -301,6 +301,16 @@ function ( $taxonomy ) use ( $news_post_types ) { ), ) ); + require_once( VOICEWP_PATH . '/speechAssets/utterances.php' ); + + $intent_schema = ''; + + foreach ( $news_utterances as $intent => $utterances ) { + foreach ( $utterances as $utterance ) { + $intent_schema .= $intent . ' ' . $utterance . "\n"; + } + } + $interaction_model = array(); $interaction_model['news_intent_schema'] = new \Fieldmanager_TextArea( array( @@ -331,7 +341,7 @@ function ( $taxonomy ) use ( $news_post_types ) { ) ), new \Fieldmanager_TextArea( __( 'Values', 'voicewp' ), array( 'name' => 'VOICEWP_POST_NUMBER_WORD_values', - 'default_value' => "first\nsecond\nthird\nfourth\nfifth", + 'default_value' => implode( "\n", $ordinals ), 'attributes' => array_merge( $readonly, array( 'style' => 'width: 50%; height: 150px; font-family: monospace;' ) @@ -373,7 +383,7 @@ function ( $taxonomy ) use ( $news_post_types ) { $interaction_model['news_utterances'] = new Fieldmanager_TextArea( array( 'label' => __( 'Here\'s a starting point for your skill\'s Sample Utterances. You can add these to your news skill in the Amazon developer console.', 'voicewp' ), 'escape' => array( 'label' => 'wp_kses_post' ), - 'default_value' => file_get_contents( __DIR__ . '/../speechAssets/news/Utterances.txt', FILE_USE_INCLUDE_PATH ), + 'default_value' => html_entity_decode( $intent_schema, ENT_QUOTES ), 'skip_save' => true, 'attributes' => array_merge( $readonly, From e13a4107699954615be53ce95d488d696a58e35a Mon Sep 17 00:00:00 2001 From: tomharrigan Date: Mon, 31 Jul 2017 22:00:42 -0400 Subject: [PATCH 5/8] add a couple translation notes --- alexa/request/certificate.php | 2 ++ alexa/request/request.php | 1 + 2 files changed, 3 insertions(+) diff --git a/alexa/request/certificate.php b/alexa/request/certificate.php index 804cf65..13dc234 100644 --- a/alexa/request/certificate.php +++ b/alexa/request/certificate.php @@ -168,8 +168,10 @@ public function verify_signature_certificate_url() { } else if ( static::SIGNATURE_VALID_HOSTNAME !== $url['host'] ) { throw new InvalidArgumentException( __( "Certificate isn't from Amazon. Request isn't from Alexa.", 'voicewp' ) ); } else if ( 0 !== strpos( $url['path'], static::SIGNATURE_VALID_PATH ) ) { + /* translators: %s: folder path */ throw new InvalidArgumentException( sprintf( esc_html__( "Certificate isn't in '%s' folder. Request isn't from Alexa.", 'voicewp' ), static::SIGNATURE_VALID_PATH ) ); } else if ( isset( $url['port'] ) && static::SIGNATURE_VALID_PORT !== $url['port'] ) { + /* translators: %s: port number */ throw new InvalidArgumentException( sprintf( esc_html__( "Port isn't %s. Request isn't from Alexa.", 'voicewp' ), static::SIGNATURE_VALID_PORT ) ); } } diff --git a/alexa/request/request.php b/alexa/request/request.php index 7b6c999..54c7887 100644 --- a/alexa/request/request.php +++ b/alexa/request/request.php @@ -89,6 +89,7 @@ public function from_data() { $request_type = $data['request']['type']; if ( ! class_exists( '\\Alexa\\Request\\' . $request_type ) ) { + /* translators: %s: type of Alexa request being made */ throw new RuntimeException( sprintf( esc_html__( 'Unknown request type: %s', 'voicewp' ), $request_type ) ); } From 8a11b3174a999a54a9b186a739aec410b8924ce5 Mon Sep 17 00:00:00 2001 From: tomharrigan Date: Mon, 31 Jul 2017 22:01:00 -0400 Subject: [PATCH 6/8] Add pot file update --- inc/lang/voicewp.pot | 394 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 381 insertions(+), 13 deletions(-) diff --git a/inc/lang/voicewp.pot b/inc/lang/voicewp.pot index 7007e31..eb9a4ce 100644 --- a/inc/lang/voicewp.pot +++ b/inc/lang/voicewp.pot @@ -3,8 +3,8 @@ msgid "" msgstr "" "Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n" "Project-Id-Version: VoiceWP\n" -"POT-Creation-Date: 2017-07-24 14:44-0400\n" -"PO-Revision-Date: 2017-07-24 14:42-0400\n" +"POT-Creation-Date: 2017-07-31 21:32-0400\n" +"PO-Revision-Date: 2017-07-31 21:31-0400\n" "Last-Translator: \n" "Language-Team: \n" "MIME-Version: 1.0\n" @@ -47,12 +47,14 @@ msgstr "" msgid "Certificate isn't from Amazon. Request isn't from Alexa." msgstr "" -#: alexa/request/certificate.php:171 +#. translators: %s: folder path +#: alexa/request/certificate.php:172 #, php-format msgid "Certificate isn't in '%s' folder. Request isn't from Alexa." msgstr "" -#: alexa/request/certificate.php:173 +#. translators: %s: port number +#: alexa/request/certificate.php:175 #, php-format msgid "Port isn't %s. Request isn't from Alexa." msgstr "" @@ -61,7 +63,8 @@ msgstr "" msgid "Alexa Request requires the raw JSON data to validate request signature" msgstr "" -#: alexa/request/request.php:92 +#. translators: %s: type of Alexa request being made +#: alexa/request/request.php:93 #, php-format msgid "Unknown request type: %s" msgstr "" @@ -316,43 +319,43 @@ msgstr "" msgid "How the above phrase should be pronounced." msgstr "" -#: inc/fields.php:307 +#: inc/fields.php:317 msgid "" "The Intent Schema for your News skill. Add this to your news skill in the Amazon developer " "console." msgstr "" -#: inc/fields.php:318 +#: inc/fields.php:328 msgid "Custom Slot Types" msgstr "" -#: inc/fields.php:322 +#: inc/fields.php:332 msgid "" "These slot types must be added to your news skill in the Amazon developer " "portal." msgstr "" -#: inc/fields.php:324 inc/fields.php:340 +#: inc/fields.php:334 inc/fields.php:350 msgid "Type" msgstr "" -#: inc/fields.php:332 inc/fields.php:348 +#: inc/fields.php:342 inc/fields.php:358 msgid "Values" msgstr "" -#: inc/fields.php:374 +#: inc/fields.php:384 msgid "" "Here's a starting point for your skill's Sample Utterances. You can add " "these to your news skill in the Amazon developer console." msgstr "" -#: inc/fields.php:385 +#: inc/fields.php:395 msgid "Interaction Model" msgstr "" -#: inc/fields.php:398 +#: inc/fields.php:408 msgid "Alexa Skill Settings" msgstr "" @@ -440,6 +443,371 @@ msgstr "" msgid "Parent Skill:" msgstr "" +#: speechAssets/utterances.php:8 +msgid "first" +msgstr "" + +#: speechAssets/utterances.php:9 +msgid "second" +msgstr "" + +#: speechAssets/utterances.php:10 +msgid "third" +msgstr "" + +#: speechAssets/utterances.php:11 +msgid "fourth" +msgstr "" + +#: speechAssets/utterances.php:12 +msgid "fifth" +msgstr "" + +#: speechAssets/utterances.php:17 +msgid "can I have the latest content" +msgstr "" + +#: speechAssets/utterances.php:18 +msgid "can I have the latest articles" +msgstr "" + +#: speechAssets/utterances.php:19 +msgid "can I have the latest stories" +msgstr "" + +#: speechAssets/utterances.php:20 +msgid "can I have the latest news" +msgstr "" + +#: speechAssets/utterances.php:21 +msgid "what is the latest content" +msgstr "" + +#: speechAssets/utterances.php:22 +msgid "what are the latest articles" +msgstr "" + +#: speechAssets/utterances.php:23 +msgid "what are the latest stories" +msgstr "" + +#: speechAssets/utterances.php:24 +msgid "what is the latest news" +msgstr "" + +#: speechAssets/utterances.php:25 +msgid "what's the latest content" +msgstr "" + +#: speechAssets/utterances.php:26 +msgid "what're the latest articles" +msgstr "" + +#: speechAssets/utterances.php:27 +msgid "what're the latest stories" +msgstr "" + +#: speechAssets/utterances.php:28 +msgid "what's the latest news" +msgstr "" + +#: speechAssets/utterances.php:29 +msgid "the latest content" +msgstr "" + +#: speechAssets/utterances.php:30 +msgid "the latest articles" +msgstr "" + +#: speechAssets/utterances.php:31 +msgid "the latest stories" +msgstr "" + +#: speechAssets/utterances.php:32 +msgid "the latest news" +msgstr "" + +#: speechAssets/utterances.php:33 +msgid "give me the latest content" +msgstr "" + +#: speechAssets/utterances.php:34 +msgid "give me the latest articles" +msgstr "" + +#: speechAssets/utterances.php:35 +msgid "give me the latest stories" +msgstr "" + +#: speechAssets/utterances.php:36 +msgid "give me the latest news" +msgstr "" + +#: speechAssets/utterances.php:37 +msgid "get the latest content" +msgstr "" + +#: speechAssets/utterances.php:38 +msgid "get the latest articles" +msgstr "" + +#: speechAssets/utterances.php:39 +msgid "get the latest stories" +msgstr "" + +#: speechAssets/utterances.php:40 +msgid "get the latest news" +msgstr "" + +#: speechAssets/utterances.php:41 +msgid "what's up" +msgstr "" + +#: speechAssets/utterances.php:42 +msgid "what's new" +msgstr "" + +#: speechAssets/utterances.php:43 +msgid "read the latest content" +msgstr "" + +#: speechAssets/utterances.php:44 +msgid "read the latest articles" +msgstr "" + +#: speechAssets/utterances.php:45 +msgid "read the latest stories" +msgstr "" + +#: speechAssets/utterances.php:46 +msgid "read the latest news" +msgstr "" + +#: speechAssets/utterances.php:47 +msgid "read me the latest content" +msgstr "" + +#: speechAssets/utterances.php:48 +msgid "read me the latest articles" +msgstr "" + +#: speechAssets/utterances.php:49 +msgid "read me the latest stories" +msgstr "" + +#: speechAssets/utterances.php:50 +msgid "read me the latest news" +msgstr "" + +#: speechAssets/utterances.php:51 +msgid "tell me the latest articles" +msgstr "" + +#: speechAssets/utterances.php:52 +msgid "tell me the latest stories" +msgstr "" + +#: speechAssets/utterances.php:53 +msgid "tell me the latest news" +msgstr "" + +#. translators: %s: taxonomy term used in Alexa utterance for latest content +#: speechAssets/utterances.php:57 +#, php-format +msgid "the latest %s articles" +msgstr "" + +#. translators: %s: taxonomy term used in Alexa utterance for latest content +#: speechAssets/utterances.php:59 +#, php-format +msgid "the latest %s content" +msgstr "" + +#. translators: %s: taxonomy term used in Alexa utterance for latest content +#: speechAssets/utterances.php:61 +#, php-format +msgid "the latest %s news" +msgstr "" + +#. translators: %s: taxonomy term used in Alexa utterance for latest content +#: speechAssets/utterances.php:63 +#, php-format +msgid "the latest %s stories" +msgstr "" + +#. translators: %s: taxonomy term used in Alexa utterance for latest content +#: speechAssets/utterances.php:65 +#, php-format +msgid "%s content" +msgstr "" + +#. translators: %s: taxonomy term used in Alexa utterance for latest content +#: speechAssets/utterances.php:67 +#, php-format +msgid "%s articles" +msgstr "" + +#. translators: %s: taxonomy term used in Alexa utterance for latest content +#: speechAssets/utterances.php:69 +#, php-format +msgid "%s stories" +msgstr "" + +#. translators: %s: taxonomy term used in Alexa utterance for latest content +#: speechAssets/utterances.php:71 +#, php-format +msgid "%s news" +msgstr "" + +#. translators: %s: taxonomy term used in Alexa utterance for latest content +#: speechAssets/utterances.php:73 +#, php-format +msgid "Get the latest %s articles" +msgstr "" + +#. translators: %s: taxonomy term used in Alexa utterance for latest content +#: speechAssets/utterances.php:75 +#, php-format +msgid "Get the latest %s content" +msgstr "" + +#. translators: %s: taxonomy term used in Alexa utterance for latest content +#: speechAssets/utterances.php:77 +#, php-format +msgid "Get the latest %s news" +msgstr "" + +#. translators: %s: taxonomy term used in Alexa utterance for latest content +#: speechAssets/utterances.php:79 +#, php-format +msgid "Get the latest %s stories" +msgstr "" + +#. translators: %s: taxonomy term used in Alexa utterance for latest content +#: speechAssets/utterances.php:81 +#, php-format +msgid "Get %s articles" +msgstr "" + +#. translators: %s: taxonomy term used in Alexa utterance for latest content +#: speechAssets/utterances.php:83 +#, php-format +msgid "Get %s content" +msgstr "" + +#. translators: %s: taxonomy term used in Alexa utterance for latest content +#: speechAssets/utterances.php:85 +#, php-format +msgid "Get %s news" +msgstr "" + +#. translators: %s: taxonomy term used in Alexa utterance for latest content +#: speechAssets/utterances.php:87 +#, php-format +msgid "Get %s stories" +msgstr "" + +#. translators: %s: number +#. translators: %s: ordinal number +#: speechAssets/utterances.php:91 speechAssets/utterances.php:113 +#, php-format +msgid "Read the %s" +msgstr "" + +#. translators: %s: number +#. translators: %s: ordinal number +#: speechAssets/utterances.php:93 speechAssets/utterances.php:115 +#, php-format +msgid "Read the %s post" +msgstr "" + +#. translators: %s: number +#. translators: %s: ordinal number +#: speechAssets/utterances.php:95 speechAssets/utterances.php:117 +#, php-format +msgid "Read the %s article" +msgstr "" + +#. translators: %s: number +#. translators: %s: ordinal number +#: speechAssets/utterances.php:97 speechAssets/utterances.php:119 +#, php-format +msgid "Read the %s story" +msgstr "" + +#. translators: %s: number +#. translators: %s: ordinal number +#: speechAssets/utterances.php:99 speechAssets/utterances.php:121 +#, php-format +msgid "Read %s" +msgstr "" + +#. translators: %s: number +#. translators: %s: ordinal number +#: speechAssets/utterances.php:101 speechAssets/utterances.php:141 +#, php-format +msgid "Read %s to me" +msgstr "" + +#. translators: %s: number +#. translators: %s: ordinal number +#: speechAssets/utterances.php:103 speechAssets/utterances.php:123 +#, php-format +msgid "Read me the %s" +msgstr "" + +#. translators: %s: number +#. translators: %s: ordinal number +#: speechAssets/utterances.php:105 speechAssets/utterances.php:125 +#, php-format +msgid "Read me the %s post" +msgstr "" + +#. translators: %s: number +#. translators: %s: ordinal number +#: speechAssets/utterances.php:107 speechAssets/utterances.php:127 +#, php-format +msgid "Read me the %s article" +msgstr "" + +#. translators: %s: number +#. translators: %s: ordinal number +#: speechAssets/utterances.php:109 speechAssets/utterances.php:129 +#, php-format +msgid "Read me the %s story" +msgstr "" + +#. translators: %s: number +#. translators: %s: ordinal number +#: speechAssets/utterances.php:111 speechAssets/utterances.php:131 +#, php-format +msgid "Read me %s" +msgstr "" + +#. translators: %s: ordinal number +#: speechAssets/utterances.php:133 +#, php-format +msgid "Read the %s to me" +msgstr "" + +#. translators: %s: ordinal number +#: speechAssets/utterances.php:135 +#, php-format +msgid "Read the %s post to me" +msgstr "" + +#. translators: %s: ordinal number +#: speechAssets/utterances.php:137 +#, php-format +msgid "Read the %s article to me" +msgstr "" + +#. translators: %s: ordinal number +#: speechAssets/utterances.php:139 +#, php-format +msgid "Read the %s story to me" +msgstr "" + #. Plugin Name of the plugin/theme msgid "VoiceWP" msgstr "" From 99bf28652ee1628d3a1362bde0b3561f2c0fe3f9 Mon Sep 17 00:00:00 2001 From: tomharrigan Date: Mon, 31 Jul 2017 22:01:23 -0400 Subject: [PATCH 7/8] load plugin text domain --- inc/class-voicewp-setup.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/inc/class-voicewp-setup.php b/inc/class-voicewp-setup.php index 1bf325b..d1f962f 100644 --- a/inc/class-voicewp-setup.php +++ b/inc/class-voicewp-setup.php @@ -167,6 +167,8 @@ public function tiny_mce_before_init( $settings ) { * @since 1.0.0 */ public function plugins_loaded() { + // Load translation files + load_plugin_textdomain( 'voicewp', false, dirname( plugin_basename( __FILE__ ) ) . '/lang' ); // Determine if the database version and code version are the same. $current_version = get_option( 'voicewp_version' ); if ( version_compare( $current_version, self::$version, '>=' ) ) { From 78f36bc7c5fc42d2d877295daef8c79cb68374e6 Mon Sep 17 00:00:00 2001 From: tomharrigan Date: Tue, 8 Aug 2017 18:59:36 -0400 Subject: [PATCH 8/8] language support tweaks --- alexa/skill/news.php | 24 +++++++++++++++++++++-- inc/lang/voicewp.pot | 46 ++++++++++++++++++++++---------------------- 2 files changed, 45 insertions(+), 25 deletions(-) diff --git a/alexa/skill/news.php b/alexa/skill/news.php index 1593759..b52c9ba 100644 --- a/alexa/skill/news.php +++ b/alexa/skill/news.php @@ -99,8 +99,13 @@ public function news_request( $request, $response ) { * unlike the case for all other numbers. */ $post_number = 2; + } elseif ( is_numeric( $maybe_post_number = substr( $post_number, 0, -2 ) ) ) { + $post_number = $maybe_post_number; } else { - $post_number = substr( $post_number, 0, -2 ); + $ordinals = array_flip( $this->get_ordinals() ); + if ( isset( $ordinals[ $post_number ] ) ) { + $post_number = $ordinals[ $post_number ]; + } } } else { $post_number = $request->getSlot( 'PostNumber' ); @@ -218,6 +223,20 @@ private function message( $response, $case = 'missing' ) { } } + /** + * Returns an array of ordinal strings that correspond to their array keys + * @return array Array of translateable ordinal strings + */ + public function get_ordinals() { + return array( + 1 => esc_html__( 'first', 'voicewp' ), + 2 => esc_html__( 'second', 'voicewp' ), + 3 => esc_html__( 'third', 'voicewp' ), + 4 => esc_html__( 'fourth', 'voicewp' ), + 5 => esc_html__( 'fifth', 'voicewp' ), + ); + } + /** * Creates output when a user asks for a list of posts. * Delivers an array containing a numbered list of post titles @@ -235,12 +254,13 @@ public function endpoint_content( $args ) { $content = $card_content = ''; $ids = array(); + $ordinals = $this->get_ordinals(); if ( ! empty( $news_posts ) && ! is_wp_error( $news_posts ) ) { foreach ( $news_posts as $key => $news_post ) { // Appending 'th' to any number results in proper ordinal pronunciation // TODO: Sounds a little strange when there's only one result. - $content .= ( $key + 1 ) . 'th, ' . $news_post->post_title . '. '; + $content .= $ordinals[ $key + 1 ] . ', ' . $news_post->post_title . '. '; $card_content .= ( $key + 1 ) . '. ' . $news_post->post_title . "\n"; $ids[] = $news_post->ID; } diff --git a/inc/lang/voicewp.pot b/inc/lang/voicewp.pot index eb9a4ce..7caeb40 100644 --- a/inc/lang/voicewp.pot +++ b/inc/lang/voicewp.pot @@ -3,8 +3,8 @@ msgid "" msgstr "" "Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n" "Project-Id-Version: VoiceWP\n" -"POT-Creation-Date: 2017-07-31 21:32-0400\n" -"PO-Revision-Date: 2017-07-31 21:31-0400\n" +"POT-Creation-Date: 2017-08-08 18:58-0400\n" +"PO-Revision-Date: 2017-08-08 18:58-0400\n" "Last-Translator: \n" "Language-Team: \n" "MIME-Version: 1.0\n" @@ -75,11 +75,31 @@ msgstr "" msgid "Latest from %s" msgstr "" -#: alexa/skill/news.php:214 +#: alexa/skill/news.php:219 msgid "" "Sorry! I couldn't find any news about that topic. Try asking something else!" msgstr "" +#: alexa/skill/news.php:232 speechAssets/utterances.php:8 +msgid "first" +msgstr "" + +#: alexa/skill/news.php:233 speechAssets/utterances.php:9 +msgid "second" +msgstr "" + +#: alexa/skill/news.php:234 speechAssets/utterances.php:10 +msgid "third" +msgstr "" + +#: alexa/skill/news.php:235 speechAssets/utterances.php:11 +msgid "fourth" +msgstr "" + +#: alexa/skill/news.php:236 speechAssets/utterances.php:12 +msgid "fifth" +msgstr "" + #: inc/class-voicewp.php:40 msgid "To test your skill, use an Alexa enabled device or Echosim.io" msgstr "" @@ -443,26 +463,6 @@ msgstr "" msgid "Parent Skill:" msgstr "" -#: speechAssets/utterances.php:8 -msgid "first" -msgstr "" - -#: speechAssets/utterances.php:9 -msgid "second" -msgstr "" - -#: speechAssets/utterances.php:10 -msgid "third" -msgstr "" - -#: speechAssets/utterances.php:11 -msgid "fourth" -msgstr "" - -#: speechAssets/utterances.php:12 -msgid "fifth" -msgstr "" - #: speechAssets/utterances.php:17 msgid "can I have the latest content" msgstr ""