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

Extending a class Locale.php #49

Closed
seb-jean opened this issue Jun 21, 2016 · 6 comments
Closed

Extending a class Locale.php #49

seb-jean opened this issue Jun 21, 2016 · 6 comments
Assignees

Comments

@seb-jean
Copy link

seb-jean commented Jun 21, 2016

I need to extend your a class in your entities folder called Locale.php for add parameter config.

How do I go about doing that?

Thanks :)

I would like have

<?php

return [
    // ...

    'locales'   => [
        // A
        //====================================================>
        'aa'         => [
            'name'   => 'Afar',
            'script' => 'Latn',
            'dir'    => 'ltr',
            'native' => 'Qafar',
            'datepicker' => 'af'
        ],

        // ...

        'zu'         => [
            'name'   => 'Zulu',
            'script' => 'Latn',
            'dir'    => 'ltr',
            'native' => 'IsiZulu',
            'datepicker' => 'zu'
        ],
    ],
];

instead of

<?php

return [
    // ...

    'locales'   => [
        // A
        //====================================================>
        'aa'         => [
            'name'   => 'Afar',
            'script' => 'Latn',
            'dir'    => 'ltr',
            'native' => 'Qafar',
        ],

        // ...

        'zu'         => [
            'name'   => 'Zulu',
            'script' => 'Latn',
            'dir'    => 'ltr',
            'native' => 'IsiZulu',
        ],
    ],
];`
@arcanedev-maroc
Copy link
Member

Hi @sebastienjean76, thanks for using this package.

When you say extending the Locale Entity class, you mean removing a parameter like regional or adding new one ??

Can you give me an example to see what you want to achieve ?

@seb-jean
Copy link
Author

Hello :)

I would like add new parameter.

It's for add locale datepicker for my project and so it's different according the language.

@arcanedev-maroc
Copy link
Member

arcanedev-maroc commented Jun 21, 2016

OK, i see what you want to achieve.

The fast/optimal solution for this is by using a config file like this (Single responsibility principle thing):

<?php 
// config/datepicker.php

return [
    'aa' => 'af',
    'zu' => 'zu',
];

And access it like this config('datepicker.' . Localization::getLocale()).

I'm going to think about it and find an eloquent way to extend the Locale entity.

@seb-jean
Copy link
Author

Ok thanks. I try this way ;).

@seb-jean
Copy link
Author

seb-jean commented Jun 21, 2016

It's config('datepicker.' . Localization::getCurrentLocale()) instead of config('datepicker.' . Localization::getLocale())

@arcanedev-maroc
Copy link
Member

My bad 😝

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

No branches or pull requests

2 participants