Universal Script πŸ“Œ
1.4k Views
867 Executions

Universal script translator

Universal Script πŸ“Œ
7 months ago
Get an executor
Please login to perform these actions:

Does it work?

No reports yet

No reports yet. Tried it? Be the first to say.

Also noticed:

Description

======================= 🌐 Universal script translator 🌐 Hello script devs! :D Today I'm sharing my universal automatic script translation code. I use it in all my major projects, and today I decided to make it public so that everyone can use it too. This code detects the player's language and automatically translates the text in a table. All you need to do is set your texts to ENGLISH in the "Translations" table. After that, simply use it in all text definitions in your script.

View Raw
-- [ ======== Define your texts in ENGLISH in the table below ======== ] --

local Translations = {
	Apple = "Apple",
	Hi = "Hey Guys!",
	Test = "This is a test XD",
	Credits = "Created by Termux_404, Open source :D"
}

-- [ ======== Source (no changes needed) ======== ] --

local cloneref = cloneref or function(o) return o end
local HttpService = cloneref(game:GetService("HttpService"))
local Players = cloneref(game:GetService("Players"))

pcall(function()
    if Players.LocalPlayer.LocaleId:lower() ~= "en-us" then
        local lang = Players.LocalPlayer.LocaleId:sub(1, 2)
        local completed, keys, texts, total = 0, {}, {}, 0

        for k, v in pairs(Translations) do
            total += 1
            keys[total], texts[total] = k, v
        end

        local function translateIndex(i)
            local text = texts[i]
            if not text then return end

            task.spawn(function()
                local ok, res = pcall(function()
                    return game:HttpGet(
                        "https://translate.googleapis.com/translate_a/single?client=gtx&sl=auto&tl="
                        .. lang .. "&dt=t&q=" .. HttpService:UrlEncode(text)
                    )
                end)

                if ok and res then
                    local data = HttpService:JSONDecode(res)
                    local translated = ""


Comments

6
Log in to join the conversation. Login
ZONROX's profile picture
ZONROX1 month ago

its not working now

1
2kr3kn's profile picture
2kr3kn6 months ago

Is it better to make a single request instead of four? For instance, by concatenating them using a separator characterβ€”say, "#": n = "text1" n2 = "test" s = n .. "#" .. n2 This allows you to bundle the requests; the processing thread splits into sub-threads, making the operation fasterβ€”much faster than executing individual requests.

1
2kr3kn's profile picture
2kr3kn6 months ago

Google translates slowly, and making a large number of requests is very costly; you can use other translation services instead.

1
breezipsettings's profile picture
breezipsettings6 months ago

@2kr3kn Dude, are you talking to your self?

1
2kr3kn's profile picture
2kr3kn6 months ago

@breezipsettings Twitter habit

2
rexzvy's profile picture
rexzvy1 month ago

@2kr3kn late but why is ts lowk funny πŸ˜‚

1

Tags

More universal scripts

See all
Script hub
1.6M
2.1M
Bumped 6 hours ago
Key System

Script hub

#12 this week

Verified script badgeSnowy Hub 500+ Games & 25600+ Features

Script hub
269.2k
120.2k
Bumped 6 hours ago
Key System
Script hub
171.3k
1.4M
Bumped 9 hours ago
Key System
Script hub
16.7k
3.2k
Bumped 11 hours ago
Key System
Paid
Script hub
17.4k
88.6k
Bumped 11 hours ago
Universal Script πŸ“Œ
2.0M
4.5k
Bumped 12 hours ago