Hướng dẫn tạo một file ngôn ngữ cho theme và plugin (ok) textdomain languages
Tạo file ngôn ngữ cho theme
Bước 1: Tải theme blank ở đây https://digwp.com/clubhouse
Bước 2: Tạo folder languages

Bước 3: load_theme_textdomain
function shapeSpace_setup() {
load_theme_textdomain( 'blank-theme', get_template_directory(). '/languages');
}
add_action('after_setup_theme', 'shapeSpace_setup');
Bước 4: vô địa chỉ https://www.icanlocalize.com/tools/create_po_from_php

Bước 5: Tải về file blank-them.po.gz giải nén ra và đổi tên thành vi.po dùng phần mềm poedit nó sẽ tự dịch thành vi.mo

Bước 6: Vào trong admin page chọn language

Bước 7: Thành quả trước và sau



Tạo file ngôn ngữ cho plugin

<?php
/*
Plugin Name: Lionel
Plugin URI: #
Description: Đây là plugin sử dụng text domain
Author: Lionel
Version: 0.1
Author URI: None
Text Domain: lionel
Domain Path: /languages
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
*/
load_plugin_textdomain( 'lionel', FALSE, basename( dirname( __FILE__ ) ) . '/languages' );
// hoặc sử dụng cách sau :)
// function my_plugin_load_plugin_textdomain() {
// load_plugin_textdomain( 'lionel', FALSE, basename( dirname( __FILE__ ) ) . '/languages' );
// }
// add_action( 'plugins_loaded', 'my_plugin_load_plugin_textdomain' );
function demo() {
_e( 'Hello World Lionel', 'lionel' );
}
add_action('wp_head', 'demo');
?>
PreviousCÁCH TẠO FILE NGÔN NGỮ CHO THEME – PLUGIN Full (ok)NextCách mở rộng Visual Composer với các phần tử nội dung tuỳ biến
Last updated
Was this helpful?