python中使用gettext进行语言国际化的方法 1.编辑源代码, 保存为gettextdemo.py import gettext catalogs = gettext.find("example ", localedir="locale", all=True) print 'catalogs:',catalogs t = gettext.translation('example', "locale 这里我使用xgettext, MAC上使用homebrew 安装, 输入命令: >brew install xgettext 即可自动完成安装, 安装后的默认目录:/usr/local/Cellar/gettext /0.19.2/, 进入/usr/local/Cellar/gettext/0.19.2/bin 可以看到有很多可执行文件 , 我们这里需要用到xgettext 和 msgfmt 回到正题, 输入以下命令生成 而po,pot都是文本文件 这一步很关键,我在弄的时候没注意到这一步, 直接把.po文件复制成.mo文件, 导致出现以下类似的情况, 掉到坑里,半天爬不出来,汗~ File "C:\env\lib\gettext.py
@[toc]gettext安装下载gettextforWindows访问官方下载页面:https://mlocati.github.io/articles/gettext-iconv-windows.html 或者直接下载:https://github.com/mlocati/gettext-iconv-windows/releases下载并解压下载最新版本的gettext0.21-xxx.zip,解压到某个目录 ,比如:C:\ProgramFiles\gettext添加到系统环境变量按Win+S搜索"环境变量"选择"编辑系统环境变量"点击"环境变量"在"系统变量"中找到Path,点击"编辑"点击"新建",添加gettext 的bin目录路径:收起代码语言:TXTAI代码解释C:\ProgramFiles\gettext\bin点击"确定"保存所有更改验证安装安装完成后,验证gettext是否正常工作:收起代码语言:TXTAI 实现多语言支持gettext是一个用于国际化(i18n)和本地化(l10n)的工具,主要用于管理软件中的文本翻译。
android --prod 有人回复这样处理: https://stackoverflow.com/questions/49829158/typeerror-tsdiagnostic-file-gettext-is-not-a-function
1.gettext模块介绍 gettext模块为Python模块和应用程序提供国际化(i18n)和本地化(l10n)服务。 它提供两套API,一套高层的类似于GNU gettext的API和一套基于类的API。前者适用于单语言的场景,并且语言的选择通常依赖于用户的locale,会全局性地影响到你整个应用程序语言的转译。 (b)编辑my_app.py,先输入以下内容 # -*- coding: utf-8 -*- import gettext _ = gettext.gettext if __name__ == " 模块时,gettext模块有两种使用方式。 , # 本程序只使用了一个域 gettext.textdomain(APP_NAME) _ = gettext.gettext if __name__ == "__main__": print
这里需要 gettext 的 msgfmt 。 安装 gettext : 这里以 CentOS 为例,其他平台安装命令放在最后面。 : 操作系统 包管理器 安装命令 Windows scoop scoop install gettext macOS HomeBrew brew install gettext GNU/Linux LinuxBrew _OSZorin OSelementaryOSPCLinuxOS apt sudo apt-get install -y gettext CentOS yum sudo yum install -y gettext FedoraMageia dnf sudo dnf install -y gettext openSUSE zypper sudo zypper install -y gettext-tools gettext-runtime pacman -S --noconfirm gettext Gentoo Linux Portage sudo emerge gettext 未经允许不得转载:w3h5 » gettext msgfmt
arg2 = Double.parseDouble(label.getText()); } else if(e.getSource() = label.setText(label.getText()+"3"); arg2 = Double.parseDouble(label.getText()); } else if(e.getSource() == button4) { label.setText(label.getText arg2 = Double.parseDouble(label.getText()); } else if(e.getSource() = label.setText(label.getText()+"7"); arg2 = Double.parseDouble(label.getText());
If you need to have gettext first in your PATH run: echo 'export PATH="/usr/local/opt/gettext/bin:$ /local/opt/gettext/lib" export CPPFLAGS="-I/usr/local/opt/gettext/include" ==> Summary ? gettext library & some software gets confused if both are in the library path. If you need to have gettext first in your PATH run: echo 'export PATH="/usr/local/opt/gettext/bin:$ /local/opt/gettext/lib" export CPPFLAGS="-I/usr/local/opt/gettext/include" ==> openssl A CA file has
().equals("+")||jb.getText().equals("-")||jb.getText().equals("*")||jb.getText().equals("/")||jb.getText ().equals("1")||jb.getText().equals("2")||jb.getText().equals("3")||jb.getText().equals("4")||jb.getText ().equals("5") ||jb.getText().equals("6")||jb.getText().equals("7")||jb.getText().equals ("8")||jb.getText().equals("9") ||jb.getText().equals("0")||jb.getText().equals(" ")) { str1=str1+jb.getText(); str2=str2+jb.getText();
//例如这样: connect(btn1,SIGNAL(clicked()),this,SLOT(getText1())); connect(btn2,SIGNAL(clicked()) ,this,SLOT(getText2())); connect(btn3,SIGNAL(clicked()),this,SLOT(getText3())); connect(btn4, SIGNAL(clicked()),this,SLOT(getText4())); connect(btn5,SIGNAL(clicked()),this,SLOT(getText5())); //然后再去实现getText1,getText2,getText3,getText4,getText5 其实五个槽函数里面的业务逻辑,只是输出对于的人名,可以说是一个业务逻辑,现在却需要五个函数,函数的作用就是为了解重复代码 } connect(myMapper, SIGNAL(mapped(int)), this, SLOT(getText(int))); //然后我们编写getText(int)这个槽函数即可 void
(); String age=this.jTextField3.getText(); String QQ=this.jTextField4.getText(); String userName=this.jTextField5.getText(); String password1=this.jPasswordField1.getText(); (); String goodsTypeName=goodsTypeNameTxt.getText(); String goodsTypeDesc=goodsTypeDescTxt.getText (); String price=this.priceTxt.getText(); String goodsDesc=this.goodsDescTxt.getText( (); String price=this.priceTxt.getText(); String goodsDesc=this.goodsDecTxt.getText()
// TODO add your handling code here: if(Salary.getText ().isEmpty()||Aim.getText().isEmpty()||Saving.getText().isEmpty()) { JOptionPane.showMessageDialog rootPane,"战胜恐惧的最好办法就是面对恐惧,乖乖把信息填全"); return; } Double money=Double.parseDouble(Salary.getText ()); Double Target=Double.parseDouble(Aim.getText()); Double saving=Double.parseDouble( Saving.getText()); double a =saving; int numofyears=0; do { int
} else { String name = input_name_edittext.getText toString()); double single_price ; if (input_price_edittext.getText ")) { single_price = 0; } else if (input_price_edittext.getText .toString()); double single_price = Double.valueOf(input_price_edittext.getText ().toString()); double single_price = Double.valueOf(input_price_edittext.getText
扩展 [root@zabbix ~]# cd /data/software/php-5.6.10/ext/gettext/ [root@zabbix gettext]# /data/php/bin/phpize [root@zabbix gettext]# . /configure --with-php-config=/data/php/bin/php-config [root@zabbix gettext]# make && make ....... [root@zabbix ~]# php -m|grep bcmath [root@zabbix ~]# php -m|grep gettext [root@zabbix ~]# 发现并没有生效! [root@zabbix ~]# php -m|grep bcmath bcmath [root@zabbix ~]# php -m|grep gettext gettext [root@zabbix
c=3&t=5", async:false});//不要忘记{} $("#getText1").html(htmlOjbect.responseText); }); //ajaxSend this).html("正在请求……"+opt.url);//此处的url就是下面的load地址 }); $("#button2").click(function(){ $("#getText2 c=5&t=5",function(result){ $(".getText3").html(result); }); }); //get() method2 ">
: JavaParser.PackageDeclarationContext): self.ast_info['packageName'] = ctx.qualifiedName().getText End line: {1} | Method name: {2}".format(ctx.start.line, ctx.methodBody().stop.line, ctx.getChild(1).getText exitMethodDeclaration(self, ctx: JavaParser.MethodDeclarationContext): c1 = ctx.getChild(0).getText ctx.getChild(3)) elif c3 == 'extends': c4 = ctx.getChild(3).getChild(0).getText (), 'fieldDefinition': ctx.getChild(1).getText() } self.ast_info['fields'
首先我们创建一个项目,写一个 RemoteService.java,并定义个 AIDL接口 IRemoteService.aidl interface IRemoteService { String getText 0x03 IRemoteService 接口 系统自动生成的这个文件中有除了我们定义 getText()方法外还生成了两个内部类 Stub和 Proxy。 当客户端调用 iRemoteService.getText()时其实是进入到 Proxy类中 getText()方法。 _data和 _reply分别为 getText()需要传递的参数和返回值, getText()无需参数,只有 String类型返回值。 这时候会执行到 onTransact()方法中的 _result=this.getText()方法。而 Stub类是在 RemoteService中实现的,故就访问到远程服务中资源了。
0, txBord.getText().length(), SPAN_EXCLUSIVE_EXCLUSIVE); txBord.setText(ss); ? SpannableString ss = new SpannableString(txUnderLine.getText()); ss.setSpan(new UnderlineSpan(), 0, txUnderLine.getText ), 0, txBullte.getText().length(), SPAN_EXCLUSIVE_EXCLUSIVE); txBullte.setText(ss); ? SpannableString ss = new SpannableString(txScaleX.getText()); ss.setSpan(new ScaleXSpan(2.5f), 0, txScaleX.getText 这样设置后,字符串 str 就和 drawable 对象对应上了,在显示时会显示 drawable,但是调用 editText.getText() 得到的还是字符串。
return createThread(null, false, closure); } 二、扩展实例方法示例 ---- 声明 InputStream 实例对象 , 该实例对象可以调用 getText 扩展方法 ; InputStream inputStream inputStream.getText() 使用 InputStream 类无法调用 getText() 方法 ; 这说明 为 InputStream 扩展的 getText 方法 , 是一个 实例方法 , 只有实例对象能调用该扩展方法 , 类无法调用该扩展方法 ; 查看为 InputStream 扩展的 getText() * @since 1.0 */ public static String getText(InputStream is) throws IOException { BufferedReader reader = new BufferedReader(new InputStreamReader(is)); return getText(reader)
(); String age=this.jTextField3.getText(); String QQ=this.jTextField4.getText(); String userName=this.jTextField5.getText(); String password1=this.jPasswordField1.getText(); (); String goodsTypeName=goodsTypeNameTxt.getText(); String goodsTypeDesc=goodsTypeDescTxt.getText (); String price=this.priceTxt.getText(); String goodsDesc=this.goodsDescTxt.getText( (); String price=this.priceTxt.getText(); String goodsDesc=this.goodsDecTxt.getText()
() { return textEditor.getText(); }}最后是客户端代码,它创建了一个文本编辑器和一个用户界面,并测试了撤销和重做操作。 ; ui.executeCommand(addCommand2); System.out.println(ui.getText()); // Hello World! // 撤销 ui.undo(); System.out.println(ui.getText()); // Hello // 撤销 ui.undo (); System.out.println(ui.getText()); // // 重做 ui.redo(); System.out.println (ui.getText()); // Hello // 重做 ui.redo(); System.out.println(ui.getText()); //