### Install Lexi Library with npm Source: https://github.com/daimond113/lexi/blob/master/README.md Install the Lexi library for use with roblox-ts projects via npm. ```sh npm i @rbxts/lexi ``` -------------------------------- ### Install Lexi CLI via pesde (Lune) Source: https://context7.com/daimond113/lexi/llms.txt Installs the Lexi CLI tool for development using the Lune runtime via pesde. ```bash # Install the CLI for development (Lune runtime) pesde add -d -t lune daimond113/lexi_cli ``` -------------------------------- ### Install Lexi CLI via pesde Source: https://context7.com/daimond113/lexi/llms.txt Installs the lexi_cli tool for development using the pesde package manager. Requires Lune runtime. ```bash # Install the CLI via pesde pesde add -d -t lune daimond113/lexi_cli ``` -------------------------------- ### Install Lexi via npm (roblox-ts) Source: https://context7.com/daimond113/lexi/llms.txt Installs the Lexi localization library for roblox-ts projects using npm. ```bash # roblox-ts installation via npm npm install @rbxts/lexi ``` -------------------------------- ### Install Lexi Library via pesde (Luau) Source: https://context7.com/daimond113/lexi/llms.txt Installs the Lexi localization library for Roblox runtime using pesde. ```bash # Luau installation via pesde # Install the library for Roblox runtime pesde add -t roblox daimond113/lexi ``` -------------------------------- ### Install Vide Framework Dependency Source: https://context7.com/daimond113/lexi/llms.txt Installs the Vide framework as a peer dependency for Lexi, required for both Luau and roblox-ts. ```bash # Required: Install Vide as a peer dependency pesde add -t roblox centau/vide ``` ```bash # or for roblox-ts: npm install @rbxts/vide ``` -------------------------------- ### Configure .env File for Lexi CLI Source: https://context7.com/daimond113/lexi/llms.txt Example of a .env file in TOML format for configuring the lexi_cli authentication token. ```toml # .env file in your project root LEXI_AUTH_TOKEN = "your-roblox-open-cloud-api-key" ``` -------------------------------- ### Install Lexi CLI with Pesde Source: https://github.com/daimond113/lexi/blob/master/README.md Use this command to add the Lexi CLI package using the pesde package manager. ```sh pesde add -t roblox daimond113/lexi pesde add -d -t lune daimond113/lexi_cli ``` -------------------------------- ### Define Lexicon in TypeScript Source: https://github.com/daimond113/lexi/blob/master/README.md Define your localization lexicon using Lexi's `lexicon` and `context` functions in TypeScript. This example uses `export =` for module compatibility. ```ts import { lexicon, context } from "@rbxts/lexi" export = lexicon("en-us", { hello: 'Hello there', pets: { hamster: context('This is my ugly old hamster')("The speaker still loves the hamster.") }, goodbyePlayer: 'Goodbye {player}, it is sad to leave you at {when:datetime}', }) ``` -------------------------------- ### Luau: Integrating Lexicon with Vide Components Source: https://context7.com/daimond113/lexi/llms.txt Demonstrates how to use static and parameterized Lexicon entries within Vide components for localized UI text. Ensure `AutoLocalize` is set to `false` on Vide elements when manually handling localization. ```luau local vide = require(game:GetService("ReplicatedStorage").roblox_packages.vide) local create = vide.create local source = vide.source local lexicon = require(script.Parent.lexicon) -- Player data source local playerCoins = source(100) local currentTime = source(os.time()) -- Create UI with localized text local function GameUI() return create "ScreenGui" { -- Static text - directly use the entry (it's already a derived source) create "TextLabel" { Name = "Title", AutoLocalize = false, -- Important: disable AutoLocalize Text = lexicon.welcomeMessage, }, -- Nested entries work the same way create "TextButton" { Name = "PlayButton", AutoLocalize = false, Text = lexicon.ui.playButton, }, -- Parameterized text - wrap in a function for reactivity create "TextLabel" { Name = "Greeting", AutoLocalize = false, Text = function() return lexicon.greeting({ playerName = game.Players.LocalPlayer.Name }) end, }, -- Dynamic values with placeholder formatting create "TextLabel" { Name = "Score", AutoLocalize = false, Text = function() return lexicon.score({ points = playerCoins() }) end, }, -- DateTime formatting create "TextLabel" { Name = "LastSeen", AutoLocalize = false, Text = function() return lexicon.lastSeen({ timestamp = currentTime() }) end, }, } end ``` -------------------------------- ### Set Lexi CLI Authentication Source: https://context7.com/daimond113/lexi/llms.txt Configures authentication for the lexi_cli tool using either an environment variable or a .env file. Requires legacy-universe:manage permission. ```bash # Option 1: Environment variable export LEXI_AUTH_TOKEN="your-roblox-api-key" ``` ```bash # Option 2: Create a .env file (TOML format) echo 'LEXI_AUTH_TOKEN = "your-roblox-api-key"' > .env ``` -------------------------------- ### Define Lexicon with Placeholder Types Source: https://context7.com/daimond113/lexi/llms.txt Defines a lexicon with various placeholder types for formatting strings, numbers, and dates. Requires importing the lexi library. ```luau local lexi = require(game:GetService("ReplicatedStorage").roblox_packages.lexi) return lexi.lexicon("en-us", { -- String (default, no type specifier needed) -- Parameter type: string playerName = "Player: {name}", -- Integer number -- Parameter type: number score = "Score: {value:int}", -- Fixed decimal number -- Parameter type: number price = "Price: ${amount:fixed}", -- General number formatting -- Parameter type: number distance = "Distance: {meters:num}m", -- Uppercase hexadecimal -- Parameter type: number colorUpper = "Color: #{rgb:HEX}", -- Lowercase hexadecimal -- Parameter type: number colorLower = "Color: #{rgb:hex}", -- Full datetime -- Parameter type: number (Unix timestamp) fullDate = "Date: {time:datetime}", -- ISO 8601 format -- Parameter type: number (Unix timestamp) isoDate = "ISO: {time:iso8601}", -- Short time only -- Parameter type: number (Unix timestamp) timeOnly = "Time: {time:shorttime}", -- Short date and time -- Parameter type: number (Unix timestamp) shortDateTime = "When: {time:shortdatetime}", -- Short date only -- Parameter type: number (Unix timestamp) dateOnly = "Date: {time:shortdate}", -- Translate (looks up another key) -- Parameter type: string dynamicText = "Status: {status:translate}", }) ``` -------------------------------- ### Push Lexicon to Roblox Cloud Source: https://context7.com/daimond113/lexi/llms.txt Pushes local lexicon definitions to Roblox's cloud localization tables using the lexi_cli tool. Compares local and remote entries for incremental updates. ```bash # Push lexicon to Roblox # Usage: lexi_cli lexi_cli 123456789 src/shared/lexicon.luau ``` -------------------------------- ### Use Lexicon in Luau UI Elements Source: https://github.com/daimond113/lexi/blob/master/README.md Create UI elements like TextLabels and assign localized text from your lexicon. For dynamic text, use a function that interpolates values. ```luau create "TextLabel" { AutoLocalize = false, Text = lexicon.hello, } create "TextLabel" { AutoLocalize = false, Text = lexicon.pets.hamster, } create "TextLabel" { AutoLocalize = false, Text = function() return lexicon.goodbye_player({ player = local_player.Name, when = time_source() }) end, } ``` -------------------------------- ### Create a Localized Text Dictionary with lexicon Source: https://context7.com/daimond113/lexi/llms.txt Use the `lexicon` function to create a type-safe localization dictionary. Define text entries, including static text, nested structures, and parameterized text with various formatting options. This function requires a source locale identifier and an object of text entries. ```luau local lexi = require(game:GetService("ReplicatedStorage").roblox_packages.lexi) local lexicon = lexi.lexicon local context = lexi.context -- Define a lexicon module (must be in its own file for CLI support) return lexicon("en-us", { -- Simple static text (becomes a derived source) welcomeMessage = "Welcome to our game!", -- Nested entries for organization ui = { playButton = "Play Now", settingsTitle = "Settings", }, -- Text with placeholders (requires parameters when called) greeting = "Hello {playerName}!", -- Various placeholder types score = "Score: {points:int}", balance = "Balance: ${amount:fixed}", lastSeen = "Last seen: {timestamp:datetime}", hexColor = "Color code: #{color:HEX}", -- With translator context for cloud translations pets = { cat = context("I love my cat")("Expresses affection for pet cat"), }, }) ``` -------------------------------- ### TypeScript: Using Lexicon in Vide Components Source: https://context7.com/daimond113/lexi/llms.txt Shows how to use Lexicon entries within Vide components in a TypeScript/roblox-ts environment. Parameterized entries are called as functions within reactive scopes. ```typescript import lexicon from "./lexicon"; import Vide, { source } from "@rbxts/vide"; const playerLevel = source(1); const playerXP = source(0); const maxXP = source(100); function StatsDisplay() { return ( lexicon.greeting({ playerName: game.Players.LocalPlayer!.Name })} /> lexicon.stats.level({ level: playerLevel() })} /> lexicon.stats.xp({ current: playerXP(), max: maxXP() })} /> ); } ``` -------------------------------- ### Use Lexicon in TSX UI Elements Source: https://github.com/daimond113/lexi/blob/master/README.md Render UI elements in TSX and assign localized text from your lexicon. Dynamic text requires a function that provides the necessary interpolation values. ```tsx lexicon.goodbyePlayer({ player: localPlayer.Name, when: timeSource() })} /> ``` -------------------------------- ### TypeScript: Defining Lexicon Entries Source: https://context7.com/daimond113/lexi/llms.txt Defines a lexicon structure using the Lexi library in TypeScript, including static strings, nested entries, and parameterized entries with type inference for placeholders. ```typescript import { lexicon, context } from "@rbxts/lexi"; import Vide from "@rbxts/vide"; // Define lexicon (in separate module) export = lexicon("en-us", { title: "My Awesome Game", greeting: "Hello {playerName}!", stats: { level: "Level: {level:int}", xp: "XP: {current:int}/{max:int}", }, shop: { buyConfirm: context("Buy for {price:int} coins?")( "Confirmation dialog when purchasing items" ), }, }); ``` -------------------------------- ### Define Lexicon in Luau Source: https://github.com/daimond113/lexi/blob/master/README.md Define your localization lexicon in a separate module using Lexi's `lexicon` and `context` functions. Ensure `AutoLocalize` is disabled on TextLabels. ```luau local lexi = require(game:GetService("ReplicatedStorage").roblox_packages.lexi) local lexicon = lexi.lexicon local context = lexi.context return lexicon("en-us", { hello = 'Hello there', pets = { hamster = context 'This is my ugly old hamster' "The speaker loves the hamster." }, goodbye_player = 'Goodbye {player}, it is sad to leave you at {when:datetime}', }) ``` -------------------------------- ### Add Translation Context with context Source: https://context7.com/daimond113/lexi/llms.txt Utilize the `context` function to add translator notes to text entries, improving clarity for cloud translations. This function is curried, accepting the source text first, then the descriptive context. It's particularly useful for ambiguous phrases and can be used within nested entries. ```luau local lexi = require(game:GetService("ReplicatedStorage").roblox_packages.lexi) local context = lexi.context return lexi.lexicon("en-us", { -- Without context simpleText = "Click here", -- With context for translators gameTitle = context("Epic Battle Arena")("The main title shown on the game's loading screen"), -- Context is especially useful for ambiguous phrases bank = context("Bank")("Refers to a financial institution, not a river bank"), -- Nested entries can also have context shop = { buyButton = context("Buy")("Button to purchase an item in the shop"), sellButton = context("Sell")("Button to sell player's inventory items"), price = "Price: {amount:int} coins", }, }) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.