5

I'm working on localization for my toolkit.

My goal is that if you were a German web developer and you wanted to use a forEach loop, rather then type ['hey', 'there'].forEach(function () {}); they could type ['hey', 'there'].fürJeder(function () {});

I have all the words stored in an object at $.i18n.de.

In my JavaScript file I have

de: {
    extend: 'verlänger',
    forEach: 'fürJeder'
}

but when I go into the object to get the words they turn into verlänger and fürJeder.

I have no idea why.

Some details:

  • I'm on a MacBook Pro running 10.6.7
  • I'm using Kod as my editor.
  • I'm using Google Chrome as my browser.
  • I'm using Option + U + letter to type the ä and ü.

My question: How do I get the browser to handle these correctly?

I've tried using backslashes before them but it stays the same.

EDIT: Screw it. I just found out that the people who inspired me to do this did it as an April Fool's day joke. I really should've clicked on some of those links. It would've saved me 2 hours of trying to set up an API.

McKayla
  • 6,879
  • 5
  • 36
  • 48
  • 1
    What encoding is your HTML page in? What encoding are your source files in? Where and when do they turn up as `verlänger`? – Pekka Apr 10 '11 at 23:24
  • 1
    Ha, that editor looks like Google Chrome! Pretty cool. – Blender Apr 10 '11 at 23:25
  • 9
    I know this is biased coming from a native English speaker, but English is the *lingua franca* of programming languages. It would be better just to learn the required English words. And what about translating the word `function`? :) – thirtydot Apr 10 '11 at 23:28
  • @Pekka It should be UTF-8 but honestly I have no idea. – McKayla Apr 10 '11 at 23:28
  • @thirtydot Excel formulae functions are localized - did you know that? – x0n Apr 10 '11 at 23:35
  • 4
    @thirtydot: I'm not a native English speaker (in fact, I'm German :D) but I agree with you :) At least if you want to become a good developer, there is no way around English. – Felix Kling Apr 10 '11 at 23:35
  • @tyler can you show a live example? – Pekka Apr 10 '11 at 23:40
  • @tyler haha! :) Never mind. Seriously though, you can do this in PHP. IIRC, PHP accepts all sorts of weird Unicode characters as function names and such. – Pekka Apr 10 '11 at 23:42
  • @tylermwashburn: LOL at your edit. @x0n: No I didn't, thanks for the info. I can kinda see why Microsoft chose to localise those functions, being that Excel is very widely used by non-computer people. – thirtydot Apr 10 '11 at 23:43
  • 1
    @thirtydot Look at their examples though!! They're so in depth. It seemed legit. xD – McKayla Apr 10 '11 at 23:46
  • 1
    @thirtydot @tylermwashburn: Great. I'm laughing so hard I won't be able to sleep now. – BoltClock Apr 10 '11 at 23:47
  • 1
    Developers knowing Javascript surely know English as well. Coding in native language is definitely something non-desirable. I'm not English and it would be natural to me to write `forEach()` instead of `fürJeder()`. I would never know which is right which part of my code calls which library and remember which language to use. Programming is best done when in English. Sorry to disappoint you though. – Robert Koritnik Apr 10 '11 at 23:52
  • @thirtydot You might appreciate the new title too. xD – McKayla Apr 10 '11 at 23:55
  • @tylermwashburn: I read that blog post on the day (I'm a closet Mootools fan). I'm surprised I didn't recognize their handiwork in your question :) – thirtydot Apr 10 '11 at 23:58
  • @thirtydot Same! :D I love MooTools. But I read it on the second and didn't pay attention to the date. xD – McKayla Apr 11 '11 at 00:06
  • 1
    @tylermwashburn: You should post the, erm, *resolution* as an answer so that this doesn't show up as being unanswered. – intuited Apr 11 '11 at 01:01

2 Answers2

1

Although I don't get the point of that (especially for german people generally comfortable with english and sharing the same germanic linguistic origin), the simplest workaround to avoid encoding issues is to replace those special characters with their latin counterparts:

fürJeder -> fuerJeder

verlänger -> verlaenger

Uncommon spelling but still correct

rb_x
  • 66
  • 2
1

Turns out that this is a really bad idea to try and do.

Programming languages are almost exclusively written in English (JavaScript being one of those) which means that even if you write your program in a different language, keywords like return, var, function are still going to be in English and you're still going to have to use them which would get confusing when using functions, constants etc. that have non-English names.

The best solution is to just avoid using non-latin characters in variable names all together.

Even thought it works in most modern browsers, it makes your code harder to write and more confusing.

Leave the coding to the English speakers.

McKayla
  • 6,879
  • 5
  • 36
  • 48