Last active
December 15, 2015 14:46
-
-
Save danielpataki/d051dfa1f952969d4004 to your computer and use it in GitHub Desktop.
Translating Plugins
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php $greeting = __( 'Hello There!', 'text-domain' ); ?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$messages = get_message_count(); | |
// Simple form | |
$text = _n( 'You have one message', 'You have lots of messages', $messages, 'my-message-app' ); | |
// Displaying the actual number | |
$text = sprintf( _n( 'You have one message', 'You %s messages', $messages, 'my-message-app' ), $messages ) | |
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
_x( 'Pair', 'A pair of people', 'my-plugin-textomaind' ); | |
_x( 'Pair', 'As in: pairing devices', 'my-plugin-textomaind' ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#: path-to-file:line-number | |
msgid "string to translate" | |
msgstr "translation goes here" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jQuery.html( "<h2>" + wma.section_title + "</h2>" ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_action( 'admin_enqueue_scripts', 'motivation_assets' ); | |
function motivation_assets($hook) { | |
wp_enqueue_script( 'motivation-scripts', plugin_dir_url( __FILE__ ) . 'scripts' ); | |
wp_localize_script( 'motivation-scripts', 'wma', array( | |
'section_title' => __( "Today's motivation", 'wp-admin-motivation' ) | |
)); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_action('plugins_loaded', 'wan_load_textdomain'); | |
function wan_load_textdomain() { | |
load_plugin_textdomain( 'wp-admin-motivation', false, dirname( plugin_basename(__FILE__) ) . '/lang/' ); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
msgid "" | |
msgstr "" | |
"Project-Id-Version: WP Admin Motivation 1.0.0\n" | |
"Report-Msgid-Bugs-To: \n" | |
"POT-Creation-Date: 2015-04-27 13:09+0100\n" | |
"PO-Revision-Date: 2015-04-27 13:09+0100\n" | |
"Last-Translator: Daniel Pataki <contact@tastique.org>\n" | |
"Language-Team: Daniel Pataki <hello@danielpataki.com>\n" | |
"Language: Hungarian\n" | |
"MIME-Version: 1.0\n" | |
"Content-Type: text/plain; charset=UTF-8\n" | |
"Content-Transfer-Encoding: 8bit\n" | |
"X-Poedit-KeywordsList: __;_e\n" | |
"X-Poedit-Basepath: .\n" | |
"X-Poedit-SearchPath-0: ..\n" | |
#: ../wp-admin-motivation.php:20 | |
msgid "You are awesome" | |
msgstr "" | |
#: ../wp-admin-motivation.php:21 | |
msgid "This website is boss" | |
msgstr "" | |
#: ../wp-admin-motivation.php:22 | |
msgid "You look great today" | |
msgstr "" | |
#: ../wp-admin-motivation.php:23 | |
msgid "Your earlobes are well rounded, good job!" | |
msgstr "" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#wp-admin-motivation { | |
float: right; | |
padding-right: 15px; | |
padding-top: 7px; | |
margin: 0; | |
font-size: 11px; | |
} | |
.rtl #wp-admin-motivation { | |
float: left; | |
padding-left: 15px; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$motivation = array( | |
__( 'You are awesome', 'wp-admin-motivation'), | |
__( 'This website is boss', 'wp-admin-motivation'), | |
__( 'You look great today', 'wp-admin-motivation'), | |
__( 'Your earlobes are well rounded, good job!, 'wp-admin-motivation')' | |
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
Plugin Name: Admin Motivation | |
Plugin URI: http://danielpataki.com | |
Description: Shows motivational messages in the admoin bar | |
Author: Daniel Pataki | |
Version: 1.0 | |
Author URI: http://danielpataki.com | |
Text Domain: wp-admin-motivation | |
*/ | |
function get_motivation_text() { | |
$motivation = array( | |
'You are awesome', | |
'This website is boss', | |
'You look great today', | |
'Your earlobes are well rounded, good job!' | |
); | |
shuffle( $motivation ); | |
return $motivation[0]; | |
} | |
add_action( 'admin_notices', 'show_motivation_text' ); | |
function show_motivation_text() { | |
$text = get_motivation_text(); | |
echo "<p id='wp-admin-motivation'>$text</p>"; | |
} | |
add_action( 'admin_enqueue_scripts', 'motivation_assets' ); | |
function motivation_assets($hook) { | |
wp_enqueue_style( 'motivation-styles', plugin_dir_url( __FILE__ ) . 'styles.css' ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
There’s a typo in translated-array.php: the single quote at the very end should be after