Git Product home page Git Product logo

athena-locales's Introduction

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

athena-locales's People

Contributors

frankofm avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Forkers

jonasesser

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.