Download the PHP package wecansync/laravel-translations without Composer

On this page you can find all versions of the php package wecansync/laravel-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-translations

Laravel Translation Management

Current version Monthly Downloads Total Downloads codecov

Overview

Laravel Translation Management is a package designed to simplify the management of translations in Laravel applications. It allows you to store translations in a dedicated database table, making it easy to manage multiple languages and update translations as needed.

Features

Installation

You can install the package via Composer:

Publish config file

Usage

Step 1: Update Your Model

In your Category model (or any model you wish to manage translations for), add the HasTranslations trait and define the $translation_model property

Step 2: Create Blade Form

Create a Blade form for adding category translations. The form should include fields for each language you want to support.

Here's an example for English and Arabic:

English language: Use language ID (example: 1).

translations[1][name]: English translation of the category name (string)

Arabic language: Use language ID (example: 2).

translations[2][name]: Arabic translation of the category name (string)

This ensures the translation fields are correctly linked to their respective language IDs.

Example Blade form:

Step 3: Retrieve Translation Data

You can easily retrieve translation data using the getTranslations() function. This function allows you to fetch translations for a specific field in a specified language.

Parameters

  1. languageId (required):
    The ID of the language for which you want to retrieve the translation.

  2. fieldName (required):
    The name of the field you want to retrieve the translation for.

  3. key (optional):
    • This parameter allows you to fetch translation data using a specific key instead of the default language ID.
    • Useful when you need to query translations based on a custom identifier.

Example Usage

Handling Missing Translations

If a translation does not exist for the specified language or field, the function will return null. You can handle this accordingly in your application:

This way, you can manage translations effectively and ensure that your application behaves gracefully when translations are missing.

Step 3: Delete Translation Data

You can easily delete translation data using the clearTranslations() function. This function allows you to delete translations data for a specific model in a specified language.

Parameters

  1. languageId (required):
    The ID of the language for which you want to delete the translation.

  2. key (optional): This parameter allows you to delete translation data using a specific key instead of the default language ID.

Example Usage

Optional: Manage Translation Directly

You can manage translation data directly when storing multiple records of the main model at the same time using the withTranslations() function. This function allows you to store or update translation data for a specific model in a specified language.

Configuration

To use withTranslations(), ensure your model is configured with the following:

Parameters

  1. translations (required):
    The translations data array to store or update

Example Usage

Storing Translations

Updating Translations

Security

If you discover any security-related issues, please report them by emailing [email protected].

Contributing

Contributions are welcome! To contribute, please fork the repository and submit a pull request. Make sure to follow the coding standards and include tests for any new features.

License

The package is open-sourced software licensed under the MIT license.


All versions of laravel-translations with dependencies

PHP Build Version
Package Version
Requires php Version >=8.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 wecansync/laravel-translations contains the following files

Loading the files please wait ....