Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,12 @@ jobs:
fail-fast: true
matrix:
php: [8.0, 8.1]
laravel: [8.*, 9.*]
laravel: [8.*, 9.*, 10.*]
dependency-version: [prefer-stable]
os: [ubuntu-latest]
include:
- laravel: 10.*
testbench: 8.*
- laravel: 9.*
testbench: 7.*
- laravel: 8.*
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,16 +88,16 @@ If you discover any security related issues, please check [SECURITY](https://git

## Credits

- [Tom Witkowski](https://github.com/Gummibeer) *current maintainer*
- [Dimitrios Savvopoulos](https://github.com/dimsav) *original author*
- [David Llop](https://github.com/Lloople) *refactoring testsuite*
- [Caneco](https://github.com/caneco) *artwork*
- [Tom Witkowski](https://github.com/Gummibeer) _current maintainer_
- [Dimitrios Savvopoulos](https://github.com/dimsav) _original author_
- [David Llop](https://github.com/Lloople) _refactoring testsuite_
- [Caneco](https://github.com/caneco) _artwork_
- [All Contributors](../../contributors)

## Versions

| Package | Laravel | PHP |
|:--------------------|:------------------------------|:----------|
| :------------------ | :---------------------------- | :-------- |
| **v11.10 - v11.10** | `8.* / 9.*` | `^8.0` |
| **v11.6 - v11.9** | `5.8.* / 6.* / 7.* / 8.*` | `>=7.2` |
| **v11.4 - v11.5** | `5.6.* / 5.7.* / 5.8.* / 6.*` | `>=7.1.3` |
Expand Down
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@
},
"require": {
"php": "^8.0",
"illuminate/contracts": "^8.0 || ^9.0",
"illuminate/database": "^8.0 || ^9.0",
"illuminate/support": "^8.0 || ^9.0"
"illuminate/contracts": "^8.0 || ^9.0|^10.0",
"illuminate/database": "^8.0 || ^9.0|^10.0",
"illuminate/support": "^8.0 || ^9.0|^10.0"
},
"require-dev": {
"laravel/legacy-factories": "^1.0.4",
"mockery/mockery": "^1.3.3",
"orchestra/testbench": "^6.0 || ^7.0",
"orchestra/testbench": "^6.0 || ^7.0|^8.0",
"phpunit/phpunit": "^9.0"
},
"minimum-stability": "dev",
Expand Down
13 changes: 6 additions & 7 deletions docs/package/fallback-locale.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ If you do not want to define the default fallback locale but just get the first
'de' => [
'DE',
'AT',
'CH',
'CH',
],
]
// ...
Expand Down Expand Up @@ -93,15 +93,15 @@ protected function isEmptyTranslatableAttribute(string $key, $value): bool

Since version v5.3 it is possible to use country based locales. For example, you can have the following locales:

* English: `en`
* Spanish: `es`
* Mexican Spanish: `es-MX`
* Colombian Spanish: `es-CO`
- English: `en`
- Spanish: `es`
- Mexican Spanish: `es-MX`
- Colombian Spanish: `es-CO`

To configuration for these locales looks like this:

```php
'locales' => [
'locales' => [
'en',
'es' => [
'MX',
Expand All @@ -119,4 +119,3 @@ We can also configure the "glue" between the language and country. If for instan
What applies for the fallback of the locales using the `en-MX` format?

Let's say our fallback locale is `en`. Now, when we try to fetch from the database the translation for the locale `es-MX`but it doesn't exist, we won't get as fallback the translation for `en`. Translatable will use as a fallback `es` \(the first part of `es-MX`\) and only if nothing is found, the translation for `en` is returned.

5 changes: 1 addition & 4 deletions docs/package/interface.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,8 @@ interface TranslatableProtected
{
// detect if a given translation attribute value is empty or not
protected function isEmptyTranslatableAttribute(string $key, $value): bool;

// save all attached translations
protected function saveTranslations(): bool;
}
```



1 change: 0 additions & 1 deletion docs/package/locales-helper.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,3 @@ Checks if the given locale is a country specific locale.
### getLanguageFromCountryBasedLocale\(string $locale\)

Returns the language locale from given country based locale.

9 changes: 4 additions & 5 deletions docs/package/methods.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

## Preconditions

* the `locale` is set to `de`
* the `fallback_locale` is set to `en`
* our main model instance is `$post = Post::first()`
* translations are available for `en`, `de` and `fr`
- the `locale` is set to `de`
- the `fallback_locale` is set to `en`
- our main model instance is `$post = Post::first()`
- translations are available for `en`, `de` and `fr`

## Get an instance of the translation model

Expand Down Expand Up @@ -124,4 +124,3 @@ disables autoload and returns parent attributes
### static defaultAutoloadTranslations\(\)

does not change the default behavior logic

1 change: 0 additions & 1 deletion docs/package/scopes.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,3 @@ Sorts the model by a given translation column value
```php
Post::orderByTranslation('title')->get()
```

7 changes: 4 additions & 3 deletions docs/package/validation-rule-factory.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,22 +32,24 @@ This will return an array which adjusted the placeholder in key and string value
To adjust the default `format` , `prefix` or `suffix` used by the factory you can change them in the package configuration file.

{% code title="config/translatable.php" %}

```php
'rule_factory' => [
'format' => \Astrotomic\Translatable\Validation\RuleFactory::FORMAT_ARRAY,
'prefix' => '%',
'suffix' => '%',
]
```

{% endcode %}

As `format` we support the two possible variants the `fill()` method supports.

#### RuleFactory::FORMAT\_ARRAY
#### RuleFactory::FORMAT_ARRAY

This will create the dot-notation to support locale sub-arrays. `en.content`.

#### RuleFactory::FORMAT\_KEY
#### RuleFactory::FORMAT_KEY

This will create the colon separated style. `content:en`

Expand All @@ -71,4 +73,3 @@ This will use the colon style, use `{` and `}` as delimiter and use only `de` an
{% hint style="info" %}
You can only use defined locales. Every locale that's not in `Locales::all()`will throw an `InvalidArgumentException`.
{% endhint %}

1 change: 0 additions & 1 deletion docs/usage/attributes.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,3 @@ echo $post->{'title:de'}; // Mein erster Beitrag
$post->title = 'My first edited post';
echo $post->title; // My first edited post
```

1 change: 0 additions & 1 deletion docs/usage/forms.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,3 @@ $post->title = 'My first post'; // Will update the English translatable model
```php
$post->fill(['title' => 'My first post']); // Will update the English translatable model
```

9 changes: 5 additions & 4 deletions docs/usage/pivot-model.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ The package trait could also be used on [pivot models](https://laravel.com/docs/
Because the trait introduces a new relation your base model needs a primary key - we will use an auto-increment `id` column. If you want to use an UUID string column or another key you have to set/adjust more things \(tell the model and trait which is your primary key, adjust migration ...\) but even this is possible.

{% code title="RoleUser.php" %}

```php
use Illuminate\Database\Eloquent\Relations\Pivot;
use Astrotomic\Translatable\Contracts\Translatable as TranslatableContract;
Expand All @@ -17,21 +18,21 @@ class RoleUser extends Pivot implements TranslatableContract
public $incrementing = true;
}
```

{% endcode %}

{% code title="create\_role\_user\_table.php" %}

```php
Schema::create('role_user', function(Blueprint $table) {
$table->increments('id');
$table->integer('user_id')->unsigned();
$table->integer('role_id')->unsigned();

$table->unique(['user_id', 'role_id']);
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
$table->foreign('role_id')->references('id')->on('roles')->onDelete('cascade');
});
```
{% endcode %}



{% endcode %}