Code Monkey home page Code Monkey logo

com.lurking-ninja.localization-codegen's Introduction

Localization Codegen

This is a simple package to automatically generate accessor code for the Localization package's SharedTableData assets.

Installation

When you install this package it will automatically try to install the prerequisite package: Codegen.

You can choose manually installing the package or from GitHub source

Add package from git URL

Use the Package Manager's +/Add package from git URL function. The URL you should use is this:

https://github.com/LurkingNinja/com.lurking-ninja.localization-codegen.git?path=Packages/com.lurking-ninja.localization-codegen

Manual install

  1. Download the latest .zip package from the Release section.
  2. Unpack the .zip file into your project's Packages folder.
  3. Open your project and check if it is imported properly.

Usage

After the package installed, all you need to do is to set up your localization, create your Locales. When you SAVE(!) a new Shared Table asset this package generates a file in the Assets/Plugins/LurkingNinja/LocalizationCodegen folder with the same name you named your asset with the exception of all spaces will be replaced with underscore character (_) and all special characters will be omitted. Please be careful with filenames from now on, they will serve as struct name in code as well.

Actual use of the new code if fairly simple, here is an example usage code:

using UnityEngine;
using LurkingNinja.Localization;

public class LocalizationTest : MonoBehaviour
{
    private void Start() => Debug.Log(I18N.New_Table.Test);
}

This example carries a couple of assumptions:

  • created the new Table with the default name of "New Table"
  • created a new entry in it called "Test"
  • SAVED your changes (the AssetPostProcessor only run when you save your assets)

In order to make this example work

  • copy the code above and paste into a file called "LocalizationTest.cs" in your project
  • attach it to something in your scene

When you hit play, you should be able see in the console the string you assigned to the Test entry with your default locale.

From here, it's up to you how you organize your code and feel free to fork this package to your heart's content. Hope this is useful.

com.lurking-ninja.localization-codegen's People

Contributors

lurkingninjadev avatar

Stargazers

 avatar  avatar

Watchers

 avatar

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.