Heya! This isn’t anything too impressive, but I thought it might help a few people out there hoping to improve the experience for their international audience.
Why I Made It
Recently I created a private server list mechanic for a superhero roleplay game of mine. It’s nothing too fancy, but when creating it I wanted to solve a problem that my players were having: Players who speak non-english languages were tired of being in servers where most of the people speak english as they couldn’t roleplay with most of them.
While it is admirable for Roblox to try to push for a utopian like world where people from across the world play side by side, it’s not there yet. What my band-aid solution to the problem was private servers, available to all no matter what the language, but with the language of the host displayed on the list to signal potential language compatibility. That left me with a question though - how do I best visually convey to people that a server is intended for a different language audience? Of course I could just put it in text, but when scrolling through a long list of servers it’s easy to miss that key information. So instead, I decided to go with the region, as with almost every country is a colorful flag emoji.
How it Works
After doing some research, I realized that Unicode 6.0 has most major flags already available, and upon further research I realized that not only were the flags available, but that the entire conversion from localization ID to flag emoji could be fully automated!
Firstly, you need to get the player’s country code from the client using GetCountryRegionForPlayerAsync, which should return a two letter region code.
From there, simply take each letter (I personally used string.sub to index the specific letters) and use string.gsub to replace them with their equivalent regional-indicator emoji - you may have seen these emojis before on discord, often used to spell words in the emote area. What you may not have known is that when you arrange those letters into the order of a region code, it automatically translates that into the country’s flag!
So US = 🇺 + 🇸 =
If you google the resulting emoji, you’ll see it’s actually the flag emoji! From there all you need to do is automate the process, and take the resulting emoji and place it in a TextLabel / TextButton. You may now use the associated emoji to visually show where a player is located in the world!
Final Product
Here’s the result for my server list:
Here’s code that will automatically translate player region IDs to the associated flag emoji:
function getFlagEmoji()
--dictionary of regional indicators indexable by the regular letter
local regionalIndicators = {
a = "🇦",
b = "🇧",
c = "🇨",
d = "🇩",
e = "🇪",
f = "🇫",
g = "🇬",
h = "🇭",
i = "🇮",
j = "🇯",
k = "🇰",
l = "🇱",
m = "🇲",
n = "🇳",
o = "🇴",
p = "🇵",
q = "🇶",
r = "🇷",
s = "🇸",
t = "🇹",
u = "🇺",
v = "🇻",
w = "🇼",
x = "🇽",
y = "🇾",
z = "🇿",
}
-- get region ID to translate into reg-ind characters
local regionID = string.lower(game:GetService("LocalizationService"):GetCountryRegionForPlayerAsync(game.Players.LocalPlayer))
local l1 = string.sub(regionID ,1,1) --get the first letter
local l2 = string.sub(regionID ,2,2) --get the second letter
return regionalIndicators[l1]..regionalIndicators[l2] --index the regional indicators for each letter, concatenating the result into a single string that is equivalent to the flag code
end
Hope this helps someone!
-CJ