Yinglish - יענגלעשה

English spelled with Hebrew letters

The problem: I want to internationalize a program that deals mostly with text. I want it to work in right to left languages like Arabic or Hebrew, but I don’t know either of those languages. OS X and iOS have text layout engines that do complex things for strings that contain sequences of right to left, left to right, and neutral characters, so I must test. And I need data. For example, the ‘-‘ in the title is actually the last character in the title, and the “י” is the first. It’s easy to get layout wrong unless you see it in its application.

I don’t know Hebrew, but I do know the Hebrew alphabet. If I knew German, I could just use Yiddish, a right to left language that is similar to German written with Hebrew characters. I don’t know German, so I wrote Yinglish - English transliterated into Hebrew characters.

Here is a tool that takes files like Xcode projects’s en.lproj/Localizable.strings file on the command line, and replaces the replacement string portion of the file with Yinglish. It has these parts: 

localizable.l - a flex file that parse the Localizable.strings file, passing just the replacement strings to a transforming function. I’m pleased with how short this file is.

 ToYinglish.m - an Objective-C file that implements the function that returns the transformed string. I intend to use this function in my app to translate the content I'm fetching from the web.

test.strings - a test file that is processed by Xcode each time I use its Run command, so I can see that this tool still works.

Yinglish.xcodeproj - an Xcode project that wraps them all and includes the linker flags to let flex link.

Flex is an under-used tool. After the boiler-plate in the portion of the file above the %%, it is lines of pairs, with a regular expression on the left, and C code on the right. ECHO is a built-in macro for { printf(“%s”, yytext); } and yytext is a char * of the text the regular expression matched. Flex derives that into C source, and Xcode manages the original and derived files for you.

Download Yinglish Source Code [15KB]

by David Phillip Oster 5/18/2014 Open source under Apache 2 license

Or after running through Yinglish:

בי דאָועד פּהעללעףּ וֹשתאר 5/18/2014 וֹפּאן שוֹוּרכא וּנדאר אָפּאָכהא 2 לעכאנשא