我做了这个功能:
function transliterate(word){
var answer = "";
A = new Array();
A["?"]="YO";A["?"]="I";A["?"]="TS";A["?"]="U";A["?"]="K";A["?"]="E";A["?"]="N";A["?"]="G";A["?"]="SH";A["?"]="SCH";A["?"]="Z";A["?"]="H";A["?"]="'";
A["?"]="yo";A["?"]="i";A["?"]="ts";A["?"]="u";A["?"]="k";A["?"]="e";A["?"]="n";A["?"]="g";A["?"]="sh";A["?"]="sch";A["?"]="z";A["?"]="h";A["?"]="'";
A["?"]="F";A["?"]="I";A["?"]="V";A["?"]="A";A["?"]="P";A["?"]="R";A["?"]="O";A["?"]="L";A["?"]="D";A["?"]="ZH";A["?"]="E";
A["?"]="f";A["?"]="i";A["?"]="v";A["?"]="a";A["?"]="p";A["?"]="r";A["?"]="o";A["?"]="l";A["?"]="d";A["?"]="zh";A["?"]="e";
A["?"]="YA";A["?"]="CH";A["?"]="S";A["?"]="M";A["?"]="I";A["?"]="T";A["?"]="'";A["?"]="B";A["?"]="YU";
A["?"]="ya";A["?"]="ch";A["?"]="s";A["?"]="m";A["?"]="i";A["?"]="t";A["?"]="'";A["?"]="b";A["?"]="yu";
for (i in word){
if (A[word[i]] === 'undefined'){
answer += word[i];
}
else {
answer += A[word[i]];
}
return answer;
}
}
Run Code Online (Sandbox Code Playgroud)
现在它应该将西里尔文本音译为拉丁语,让拉丁语简单地通过.但是它只能设法在第一个音译之后进行音译,而在拉丁语的情况下它会给出未定义的答案.任何人都可以给我一个想法,我做错了什么?
我遵循了本教程,这是我到目前为止所得到的:
#!/usr/bin/python
# -*- coding: utf-8 -*-
#http://www.ibm.com/developerworks/library/os-autogimp/
from gimpfu import*
def plugin_main(timg, tdrawable, maxh=540, maxw=800):
currentWidth = tdrawable.width
currentHeight = tdrawable.height
newWidth = currentWidth
newHeight = currentHeight
if (maxw < newWidth):
newWidth = maxw
newHeight = (float(currentHeight) / (float(currentWidth) / newWidth))
if (maxh < newHeight):
newHeight = maxh
newWidth = (float(currentWidth) / (float(currentHeight) / newHeight))
pdb.gimp_image_scale(timg, newWidth, newHeight)
register(
"python_fu_resize",
"Saves the image at a maximum width and height",
"Saves the image at a maximum width and …Run Code Online (Sandbox Code Playgroud)