Check language

Ask about editing graphics, sounds, models, music, etc here!
Shaders (GLSL) and SNDINFO questions also go here!

Moderators: GZDoom Developers, Raze Developers

Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.
tomppa84
Posts: 8
Joined: Fri Sep 09, 2022 6:45 am
Operating System Version (Optional): Windows 10
Graphics Processor: nVidia with Vulkan support

Check language

Post by tomppa84 »

Is there a way to check language in ACS? I want to change voice acting depeding which language the player is using.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 48519
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: Check language

Post by Graf Zahl »

Yes, you can check the 'language' CVAR, but be aware that this may be a bit tricky with languages that have multiple variants.
The language CVAR can be two or three letters, where the third letter defines a language variant.
For example, English can be enu for US, eng for UK, ena for Australia plus several others. Unless you want to support such variants, only check the first two letters.
tomppa84
Posts: 8
Joined: Fri Sep 09, 2022 6:45 am
Operating System Version (Optional): Windows 10
Graphics Processor: nVidia with Vulkan support

Re: Check language

Post by tomppa84 »

I see,thank you!
tomppa84
Posts: 8
Joined: Fri Sep 09, 2022 6:45 am
Operating System Version (Optional): Windows 10
Graphics Processor: nVidia with Vulkan support

Re: Check language

Post by tomppa84 »

hmm How do I actually do the check in ACS?
I have tried this and it prints "finnish" in any language.

Code: Select all

	str language = GetCVarString("language");

	if (Strcmp(language, "FI") == 1)
		print(s:"finnish");
	else
		print(s:"something else");
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 48519
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: Check language

Post by Graf Zahl »

strcmp returns 0 for equality.
But you'd be better off doing the check like this

Code: Select all

if (stricmp(strleft(language, 2), "FI") == 0)
to account for lower case content and sub-languages.
tomppa84
Posts: 8
Joined: Fri Sep 09, 2022 6:45 am
Operating System Version (Optional): Windows 10
Graphics Processor: nVidia with Vulkan support

Re: Check language

Post by tomppa84 »

Work's perfeckt! Thanks!

Return to “Assets (and other stuff)”