Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to return English "en" as a default language if translate is NULL (not set)? #161

Closed
mnarbash opened this issue Jul 27, 2020 · 1 comment
Assignees
Labels

Comments

@mnarbash
Copy link

mnarbash commented Jul 27, 2020

Screen Shot 2020-07-27 at 23 07 30

{
    "id": 6,
    "slug": "train2",
    "parent_id": 2,
    "position": null,
    "is_active": 1,
    "created_at": "2020-07-25T20:03:55.000000Z",
    "updated_at": "2020-07-25T20:03:55.000000Z",
    "items": [],
    "name": null,
    "translations": [
        {
            "id": 4,
            "category_id": 6,
            "locale": "en",
            "name": "Train2",
            "created_at": null,
            "updated_at": null
        }
    ]
}

in the above example code, I have used translation to switch between English "en" and Turkish "tr", and I didn't
write any translation related to Turkish, so when I choose "tr" language it gives me the name filed is null.
so how can I make the default translation language to be "en" if I have any NULL values.

@Gummibeer Gummibeer self-assigned this Jul 28, 2020
@Gummibeer
Copy link
Member

Hey,

have you checked the documentation regarding fallback locale?
https://docs.astrotomic.info/laravel-translatable/package/fallback-locale

In v12 the behavior will change in the package/core and allow much more flexibility but will kind of be backwards compatible. #129

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

2 participants