You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Should you come across any glitches in our documentation, your discerning eye is much appreciated. If you've got a solution itching to be implemented, feel free to submit a PR – we welcome your contribution.
6
+
# Contributing to the Docs
7
+
8
+
We believe that documentation is just as important as code, and we're always looking for ways to improve it. If you find any issues with our documentation, or if you have any suggestions for how we can make it better, we'd love to hear from you.
9
+
10
+
If you're interested in contributing to the documentation, you can do so by submitting a pull request to the [Translatable repository on GitHub](https://github.com/Javaabu/translatable). The documentation is located in the `/docs` directory, and it's written in Markdown.
11
+
12
+
We use [Docusaurus](https://docusaurus.io) to generate our documentation website, so you can use all of the features that Docusaurus provides, such as:
7
13
8
-
For your reference, each project's documentation resides snugly in the /docs folder. That's the hub where everything documentation-related unfolds. Just so you're in the loop, we employ [Docusaurus](https://docusaurus.io) to transform those markdown files into the HTML served to the public. And since we are using Docusaurus, there's a lot of special magic that you can use to make the docs even better. Here are a few resources that will be useful:
9
14
-[Markdown Front Matter](https://docusaurus.io/docs/markdown-features#front-matter)
Getting started with Translatable is a straightforward process. This guide will walk you through installing the package, configuring it, and setting up your models to be translatable.
9
+
10
+
## 1. Installation
11
+
12
+
First, pull the package into your project using Composer:
9
13
10
14
```bash
11
15
composer require javaabu/translatable
12
16
```
13
17
14
-
# Publishing the config file
18
+
Laravel's package auto-discovery feature will automatically register the necessary service provider.
19
+
20
+
## 2. Publishing Assets
21
+
22
+
Next, you'll need to publish the package's assets. This includes migrations, configuration files, and optional views.
23
+
24
+
### Migrations
25
+
26
+
Publish the migrations file, which will add a `languages` table to your database:
Translatables currently provides **two** different types of translatables, `Db` and `Json`. Check out [Difference between DB and JSON translatable](./basic-usage/difference-isdbtranslatable-isjsontranslatable.md) to learn the differences and design considerations for both
90
+
Now for the fun part! To make an Eloquent model translatable, you need to perform two steps: update its migration and add a trait to the model itself.
52
91
53
-
## Setting up your migrations
92
+
Translatable offers two strategies for storing translations:
54
93
55
-
If you are setting up a new model, you can simply add either `$table->dbTranslatable();` or `$table->jsonTranslatable();` into your migration schema create function.
94
+
-**Database-based (`DbTranslatable`):** Stores each language as a new row in the model's table. Better for complex queries and indexing.
95
+
-**JSON-based (`JsonTranslatable`):** Stores all translations in a single JSON column. Simpler and requires fewer database queries.
56
96
57
-
:::warning
97
+
:::tip
98
+
To understand the pros and cons of each approach, check out the [Difference between DB and JSON translatable](./basic-usage/difference-isdbtranslatable-isjsontranslatable.md) page.
99
+
:::
58
100
59
-
Use one or the other, **DON'T use both at the same time**.
101
+
### Step 3.1: Update the Migration
60
102
61
-
:::
103
+
You need to add the necessary columns to your model's table. Choose **one** of the following methods.
62
104
63
-
```php
64
-
use Javaabu\Translatable\DbTranslatable\DbTranslatableSchema;
Copy file name to clipboardExpand all lines: docs/intro.md
+8-4Lines changed: 8 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,11 +3,13 @@ title: Introduction
3
3
sidebar_position: 1.0
4
4
---
5
5
6
-
# Translatable
6
+
# Introduction
7
7
8
-
[Translatable](https://github.com/Javaabu/translatable)adds multi-lingual to Laravel models.
8
+
Welcome to the documentation for Translatable, a Laravel package that adds multi-lingual support to your models.
9
9
10
-
This package allows Laravel model attributes to be translated automatically according to the current `app()->getLocale()`.
10
+
This package allows your Laravel model attributes to be translated automatically according to the current `app()->getLocale()`. This means you can easily create applications that cater to a global audience, without having to worry about the complexities of localization.
11
+
12
+
Here's a quick example of how it works:
11
13
12
14
```php
13
15
app()->setLocale('en');
@@ -20,9 +22,11 @@ $post->title_en // This is an English title
20
22
$post->title_dv // Mee dhivehi title eh
21
23
```
22
24
23
-
Adding a translation is made easier as well using the language code suffix.
25
+
As you can see, it's incredibly simple to get and set translations for your model attributes. You can even add new translations on the fly:
24
26
25
27
```php
26
28
// to add title for dv language
27
29
$post->title_dv = "Mee Dhivehi title eh";
28
30
```
31
+
32
+
Throughout this documentation, we'll explore all the features of Translatable in detail, from basic usage to advanced customization. We'll also cover how to contribute to the project and where to find help if you need it.
Find yourself stuck using the package? Found a bug? Do you have general questions or suggestions for improving this package? Feel free to create an [issue](../../issues) on GitHub, we'll try to address it as soon as possible.
6
+
# Questions & Security
7
7
8
-
If you've found a bug regarding security please mail [info@javaabu.com](mailto:info@javaabu.com) instead of using the issue tracker.
8
+
Do you have a question? Is something not working as expected? Have you found a bug? Or maybe you have a suggestion for a new feature? We'd love to hear from you! Please feel free to create an [issue on GitHub](https://github.com/Javaabu/translatable/issues), and we'll do our best to get back to you as soon as possible.
9
+
10
+
## Security Vulnerabilities
11
+
12
+
If you discover a security vulnerability within this package, please send an e-mail to [info@javaabu.com](mailto:info@javaabu.com). All security vulnerabilities will be promptly addressed.
13
+
14
+
We take security very seriously, and we appreciate your help in keeping this package secure.
0 commit comments