Free Function Friday Ep.18 – getAELanguage

January 22nd 2016 08:00:47am

Welcome to Free Function Friday. This function helps return the basic string name of the language that After Effects is running in. Normally calling the language attribute will return an enumerated value like 1612. Not very handy if you don’t know what language that refers to, and also not handy when the potential for each version of After Effects having changed those numbers is a possibility.

If you ever decide to make multi-language versions of your scripts, you will need to check for the language that After Effects is currently running in, so why not get a simple answer. We’ll do all of the rough stuff today so you don’t have to do it tomorrow, or the next day, and hopefully never again. Ok, maybe not never, but not nearly as much at least.

Normally you get the language version by calling…

app.language;

To compare and see if the current language is specifically, say English (enumerated as 1612 in AE CC 2014) then you would have to type it this way…

//Check if language is English
if(app.language == Language.ENGLISH){
	alert("Language is English.");
}

That second part, looks a bit odd, but it is the format that we have to use. When directly comparing values we use the term Language with a capital L, and the second attribute is the language name in all caps. In this case it is ENGLISH. As of After Effects CC 2014 the language options are:

ENGLISH
CHINESE
FRENCH
GERMAN
ITALIAN
JAPANESE
KOREAN
SPANISH
RUSSIAN
PORUGUESE

Source Code:

alert(getAELanguage());
/*	TESTING ABOVE	*/

function getAELanguage(){
	var lang = new Array({'L': Language.ENGLISH, 'N': "English"},
		{'L': Language.CHINESE, 'N': "Chinese"},
		{'L': Language.FRENCH, 'N': "French"},
		{'L': Language.GERMAN, 'N': "German"},
		{'L': Language.ITALIAN, 'N': "Italian"},
		{'L': Language.JAPANESE, 'N': "Japanese"},
		{'L': Language.KOREAN, 'N': "Korean"},
		{'L': Language.SPANISH, 'N': "Spanish"},
		{'L': Language.RUSSIAN, 'N': "Russian"},
		{'L': Language.PORTUGUESE, 'N': "Portuguese"});
	for(var l=0; l<lang.length; l++){
		if(app.language == lang[l].L){
			return lang[l].N;
		}
	}
}
Checkout more:
Houdini Mardini Grass
Cinema4D Attach Splines To Alembics
Houdini Mardini Beach
After Effects ExtendScript Training: Ep. 19 Part 2
After Effects ExtendScript Training: Ep. 18 Part 3