Skip to content

FrankoFM/athena-locales

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Athena-Locales Plugin

Description

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.

Features

  • 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

Usage

Server

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.

Client

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.

Webview

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")'/>

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published