php i18n gettext 實現多語言
<?php
header("Content-type: text/html; charset=utf-8");
$lng = $_GET['lng'] ? $_GET['lng'] :'zh_TW';
$domain = 'test';
putenv('LANG='.$lng);
setlocale(LC_ALL, $lng); // 指定要用的語系,如:en_US、zh_CN、zh_TW
bindtextdomain($domain, '/home/dfct/test');
bind_textdomain_codeset($domain, 'UTF-8');
textdomain($domain);
//($_ENV);
// E:/wwwroot/test/zh_TW/LC_MESSAGES/test.mo
echo _("中文");
E:\wwwroot\test\en_US\LC_MESSAGES\test.mo
生成po 和pot檔案用 poedit 比較方便
相關推薦
php i18n gettext 實現多語言
<?php header("Content-type: text/html; charset=utf-8"); $lng = $_GET['lng'] ? $_GET['lng'] :'zh_TW'; $domain = 'test'; putenv('LA
在LUA中使用GETTEXT實現多語言支援
在Lua中使用gettext實現多語言支援 GNU gettext 是一套優秀的國際化工具。在 linux 中被大量採用。wordpress 也使用 gettext 實現多語言支援。 本文介紹如何在 quick-cocos2d-x 中使用 gettext 做多語言支
利用vue-i18n實現多語言切換
在angular中有ngx-translate解決i18n的需求,vue也具備這樣的能力,利用vue-i18n,我們可以實現多語言的切換,可以輕鬆搞定大部分的需求,包括中英文切換,以及詞條的變更。詞條變更在基線版本真的是經常會遇到的,本人深有體會。不扯淡了,說一下vue-i18n基本的使
nuxt.js實戰之用vue-i18n實現多語言
一、實現步驟 1、安裝vue-i18n並且建立store.js(vuex狀態管理)檔案 2、建立一個(middleware)中介軟體,用來管理不同的語言 3、建立不同語言的json檔案作為語言包(例如: ~locales/en.json) 4、在pages資料夾下建立檔案,並進行翻譯 二、詳細步驟
vue用i18n實現多語言支援(國際化)
vue-i18n是用於多語言適配的vue外掛,主要用於前端專案的國際化應用。 個簡單的例子: <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title&
使用vue-i18n實現多語言
1. 前言 (1) 需求 Vue工程,需要實現多語言切換功能。 (2) vue-i18n外掛 npm中對vue-i18n的描述及文件 我們將使用這個外掛實現多語言。 (3) 相容性 支援Vue.js 2.x以上版本
vue-i18n 實現多語言切換
首先安裝 npm install vue-i18n 然後在main.js 中引入: import Vue from 'vue' import VueI18n from 'vue-i18n'
ionic2 基於ngx-translate實現多語言切換,翻譯
click create -a fault template con 設置 切換 使用 介紹 ngx-translate 是Angular 2+的國際化(i18n)庫,在github的地址是箭頭 https://github.com/ngx-translate/core 將
Qt跨平臺(window、linux)實現多語言
linx this delet set 就是 body http mes else 在項目中,實現多語言基本山是基本需求,雖然Qt支持跨平臺,但在linux和windows上實現多語言的方式還是細微區別的,廢話不多說,直接進入主題吧。 Qt實現多語言,是用過QTr
PHP如何有效實現多視頻同時上傳功能
現在 method 成功 reac table 網站 controls max bsp 視頻的出現讓網站更加有生有色,對於php上傳視頻而言,我需要實現多視頻上傳,視頻播放功能,靜音功能,全屏播放,下載視頻功能等一體的需求,接下來就為大家詳細講解一下如何實現多視頻同時上傳這
MessageBox中按鈕如何實現多語言
如何正確輸出Byte?瀏覽器程式碼中如何插入廣告過濾規則如何正確輸出Byte?瀏覽器程式碼中如何插入廣告過濾規則 C#呼叫C++DLL的難題C#字元常量的表示C#呼叫C++DLL的難題C#字元常量的表示 C#呼叫C++DLLC++DLL向C#發訊息。GridView出現重複的
ThinkPHP 5 框架實現多語言 例項講解
ThinkPHP 5 框架實現多語言 今天給大家分享一篇tp5框架多語言的例項 第一步: 您需要在配置檔案中開啟網站多語言, 並新增語言允許列表: // 預設語言 'default_lang' => 'zh-cn',
遊戲實現多語言版本(國際化)
公司從今天開始放假,希望抽年假的時間,把這在新專案中所做的,分模組做個整理。 此時我正在G1152次高鐵上,寫這篇部落格,回去也沒有網,要等年後來了才能發。 自從換了專案組之後一直都很忙,沒什麼時間寫blog了,目前這個專案是自己挑的,希望多花點時間,把它做好。 因為專案還
Java實現多語言切換
在一個專案中涉及到中英文版本,一般在登入頁或者首頁的時候會有中英文連線 這個連線可以這樣寫: <div class="flag"> <s:url id="localeUsUrl" action="localeUs"></s:url&g
C# 實現多語言介面
建立一個存放語言的XML檔案 迴圈遍歷介面上的控制元件。 private void getLanguage(string LanguageCode) { string FileName; Fi
so easy 前端簡單實現多語言
前言其實現在開發者解決多語言普遍三種解決方案:第一個是為每個頁面提供每種語言的相關頁面。第二種是把內容從表現形式中分離出來,做不同語言的內容檔案。第三種是動態翻譯頁面內容。第三種很少見,而且機器翻譯技術還很難達到人們的預期。其實第二種相對來說簡單一點,那麼開搞。實現思考翻譯公
資原始檔實現多語言介面
這裡介紹的方法是使用不同語言的資原始檔達成多語言的效果。 多語言DLL 第一步:建立一個MFC的DLL 第二步:設定工程屬性為Resource DLL,如果在 .Net 2003中這一步非常簡單: Project Property->Linker->
.net 使用資原始檔實現多語言切換
1,建幾個你需要的語言資原始檔,如圖:2,public class Localization3Attribute : ActionFilterAttribute { public override void OnActionExecuting(Action
實現多語言自動切換
1.在Home(你取的專案名)的config.php中新增如下配置 <?php return array( //'配置項'=>'配置值' 'LANG_SWITCH_ON' => true, //開啟語言包功能
SpringMVC+Freemarker+jQuery實現多語言(國際化)切換
一、spring啟動配置檔案修改 其中<value>message/messages</value>指定的properties資原始檔名, 檔案在src/main/resources根目錄的message資料夾下 <!-- 資原始檔