Last active
August 29, 2015 14:10
-
-
Save danielpataki/d4fb407b47658f0eb17c to your computer and use it in GitHub Desktop.
Internationalization
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
$name = __( 'My Stats', 'textdomain' ); |
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
<h1><?php _e( 'My Stats', 'textdomain' ) ?></h1> |
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
$comment_count = get_comments_number(); | |
$comment_count_text = _n( 'One Comment', 'Many Comments', $comment_count, 'textdomain' ); |
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 | |
$to_post = _x( 'Post', 'The action of creating a post', 'textdomain' ); | |
$a_post = _x( 'Post', 'The name of a post type', 'textdomain' ); | |
?> | |
<h1><?php _ex( 'Read Posts', 'Posts with a status of read', 'textdomain' ) ?></h1> | |
<a href="<?php echo get_permalink() ?>"><?php _ex( 'read post', 'Action of reading a post', 'textdomain' ) ?></a> | |
<?php | |
$read_count_text = _nx( 'One Read Posts', 'Many Read Posts', $read_count, 'Number of read posts', 'textdomain' ); | |
?> |
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
<a href="<?php the_permalink() ?>" title="<?php sprintf( esc_attr_e( "Read %s In Full", 'textdomain' ), the_title_attribute( 'echo=false' ) ) ?>"><?php the_title() ?></a> |
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
$labels = array( | |
'name' => _x( 'Books', 'post type general name', 'your-plugin-textdomain' ), | |
'singular_name' => _x( 'Book', 'post type singular name', 'your-plugin-textdomain' ), | |
'menu_name' => _x( 'Books', 'admin menu', 'your-plugin-textdomain' ), | |
'name_admin_bar' => _x( 'Book', 'add new on admin bar', 'your-plugin-textdomain' ), | |
'add_new' => _x( 'Add New', 'book', 'your-plugin-textdomain' ), | |
'add_new_item' => __( 'Add New Book', 'your-plugin-textdomain' ), | |
'new_item' => __( 'New Book', 'your-plugin-textdomain' ), | |
'edit_item' => __( 'Edit Book', 'your-plugin-textdomain' ), | |
'view_item' => __( 'View Book', 'your-plugin-textdomain' ), | |
'all_items' => __( 'All Books', 'your-plugin-textdomain' ), | |
'search_items' => __( 'Search Books', 'your-plugin-textdomain' ), | |
'parent_item_colon' => __( 'Parent Books:', 'your-plugin-textdomain' ), | |
'not_found' => __( 'No books found.', 'your-plugin-textdomain' ), | |
'not_found_in_trash' => __( 'No books found in Trash.', 'your-plugin-textdomain' ) | |
); |
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
function myplugin_init() { | |
$plugin_dir = basename(dirname(__FILE__)); | |
load_plugin_textdomain( 'my-plugin', false, $plugin_dir ); | |
} | |
add_action('plugins_loaded', 'myplugin_init'); |
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
$("#message").html( objectL10n.message ); |
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( 'wp_enqueue_scripts', 'my_theme_scripts' ); | |
function my_theme_scripts() { | |
wp_enqueue_script( 'theme-script', get_template_directory_url() . '/js/theme-script.js' ); | |
wp_localize_script( 'theme-script', 'objectL10n', array( | |
'message' => __( 'Well Done', 'textdomain' ), | |
) ); | |
} |
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
$messages = array( | |
'post' => _n_noop('%s post', '%s posts'), | |
'page' => _n_noop('%s pages', '%s pages') | |
); | |
... | |
$message = $messages[$type]; | |
$usable_text = sprintf( translate_nooped_plural( $message, $count, $domain ), $count ); |
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
$comment_count = get_comments_number(); | |
$comment_count_text = sprintf( _n( 'One Comment', '%s Comments', $comment_count, 'textdomain' ), $comment_count ); |
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
$name = 'Daniel'; | |
echo sprintf( '%s says hello!', $name ); |
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
/* | |
Theme Name: Twenty Fifteen | |
Theme URI: https://wordpress.org/themes/twentyfifteen | |
Author: the WordPress team | |
Author URI: https://wordpress.org/ | |
Description: Our 2015 default theme is clean, blog-focused, and designed for clarity. Twenty Fifteen's simple, straightforward typography is readable on a wide variety of screen sizes, and suitable for multiple languages. We designed it using a mobile-first approach, meaning your content takes center-stage, regardless of whether your visitors arrive by smartphone, tablet, laptop, or desktop computer. | |
Version: 0.1 | |
License: GNU General Public License v2 or later | |
License URI: http://www.gnu.org/licenses/gpl-2.0.html | |
Tags: black, blue, gray, pink, purple, white, yellow, dark, light, two-columns, left-sidebar, fixed-layout, responsive-layout, accessibility-ready, custom-background, custom-colors, custom-header, custom-menu, editor-style, featured-images, microformats, post-formats, rtl-language-support, sticky-post, threaded-comments, translation-ready | |
Text Domain: twentyfifteen | |
This theme, like WordPress, is licensed under the GPL. | |
Use it to make something cool, have fun, and share what you've learned with others. | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment