This is a modified version of the Athena Locales System to provide a more flexible and easy to use locale system. You can use this plugin for free on your server and edit it to your liking. No need for credits.
- It's a plugin so that you don't have to modify the core (prevents merging errors on Athena updates)
- Each player can play in their native language (given you provide the translation)
- You can use the placeholder feature in webviews (more info about that down below)
- Uses the AgendaSystem to load the player's preferred language when he connects
Update the language for a player
const wantedLanguage = 'de';
LocalelsServer.setLanguage(player, wantedLanguage);
Get the locals for a key (without placeholder)
const message = LocalelsServer.get(player, LocalesKeys.EXAMPLE_KEY);
alt.log(message); // Returns: This is an example.
Get the locals for a key (with placeholder)
const message = LocalelsServer.get(player, LocalesKeys.EXAMPLE_KEY, 'Test');
alt.log(message); // Returns: This is an Test example.
Get the locals for a key (without placeholder)
const message = LocalesClient.get(LocalesKeys.EXAMPLE_KEY);
alt.log(message); // Returns: This is an example.
Get the locals for a key (with placeholder)
const message = LocalesClient.get(LocalesKeys.EXAMPLE_KEY, 'Test');
alt.log(message); // Returns: This is an Test example.
Get the locals for a key
- import the LocalesClient and LocalesKeys
- pack them both in the data object
Like this:
data() {
return {
LocalesClient,
LocalesKeys
};
},
And then use it like this:
<div>{{ LocalesClient.get(LocalesKeys.EXAMPLE_KEY) }}</div>
<div>{{ LocalesClient.get(LocalesKeys.EXAMPLE_KEY, 'Test') }}</div>
You can even make it convert the text to HTML like this:
- the local:
[LocalesKeys.EXAMPLE_KEY]: 'This is an <strong>_%_</strong> example.',
- the HTML / Vue:
<div v-html='LocalesClient.get(LocalesKeys.EXAMPLE_KEY, "Test")'/>