Download the PHP package nvl/laravel-typescript-translations without Composer

On this page you can find all versions of the php package nvl/laravel-typescript-translations. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package laravel-typescript-translations

Laravel TypeScript Translations

Latest Version on Packagist Total Downloads

Generate TypeScript types and translation data from Laravel translation files. Load only what you need, when you need it.

Table of Contents

The Problem This Solves

In Laravel + TypeScript apps, you typically have:

  1. Massive translation bundles - Loading all translations for all languages on every page
  2. No type safety - Typos in translation keys only discovered at runtime
  3. Poor performance - Sending unused translations over the wire

This package solves all three by:

Installation

Publish the configuration:

Quick Start

Understanding the Two Approaches

This package supports two distinct approaches for handling translations:

1. Backend-Driven (use-inertia-translations)

2. Frontend-Driven (use-local-translations)

Mode Comparison

Type Generation Modes

Mode Output Structure File Count Use Case
Single translations.d.ts 1 file Small projects (< 10 translation files)
Module vendors.types.d.ts, tasks.types.d.ts 1 per source Recommended - Balanced approach
Granular vendors/actions.types.d.ts, vendors/forms.types.d.ts 1 per file Large projects needing maximum control

Single Mode Structure

Module Mode Structure

Granular Mode Structure

Translation Export Modes

Mode Output Structure Bundle Impact Use Case
Single translations.ts No tree-shaking Small projects
Module vendors.translations.ts with multiple exports Good tree-shaking Recommended
Granular vendors/actions.ts, vendors/forms.ts Best tree-shaking Large projects

Module Mode Exports

Type Generation

Generate TypeScript types from your Laravel translations:

Options

Option Values Description
--mode single, module, granular Output structure
--locale en,bg,de Specific locales to scan
--fresh - Clear cache before generation
--debug - Show detailed output

Translation Export

Export actual translation data for frontend usage:

Options

Option Values Description
--mode single, module, granular File structure
--organize-by locale-mapped, locale, module How to organize locales
--locale en,bg,de Specific locales only
--format typescript, json Output format
--output path/to/dir Custom output directory

Hook Usage

use-inertia-translations (Backend)

For server-driven translations passed via Inertia props:

Pros:

Cons:

use-local-translations (Frontend)

For client-side translations with locale switching:

Pros:

Cons:

Combining Both Approaches

Use backend translations for initial render, client translations for dynamic features:

Laravel Integration

Middleware (Global Translations)

Only share truly global translations:

Controllers (Page-Specific)

Send only what the page needs:

Configuration Options

Complete Configuration Reference

Environment Variables

Control behavior via .env:

Per-Environment Configuration

Performance

Bundle Size Comparison

Approach Initial Load Locale Switch Tree-Shaking
Backend (Inertia) ~5KB per page Page reload N/A
Frontend (All) ~200KB Instant ❌
Frontend (Modular) ~20KB per module Instant ✅
Frontend (Dynamic) 0KB Lazy load ✅

Optimization Strategies

  1. Development: Use all translations for convenience
  2. Production: Use backend translations + dynamic imports
  3. Hybrid: Backend for SSR, frontend for interactive features

Lazy Loading Example

License

MIT. See LICENSE.md for details.


All versions of laravel-typescript-translations with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
illuminate/console Version ^12.0
illuminate/support Version ^12.0
illuminate/filesystem Version ^12.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package nvl/laravel-typescript-translations contains the following files

Loading the files please wait ...