10000 Language in packages · Issue #283 · laravel/framework · GitHub
[go: up one dir, main page]

Skip to content

Language in packages #283

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

Closed
ghost opened this issue Feb 11, 2013 · 9 comments
Closed

Language in packages #283

ghost opened this issue Feb 11, 2013 · 9 comments

Comments

@ghost
Copy link
ghost commented Feb 11, 2013

Language in packages are loading but not work

@raftalks
Copy link
Contributor

Have u tried trans('packagename::file.key');
For me it works fine.

@ghost
Copy link
Author
ghost commented Feb 11, 2013

when i used lang() :
FatalErrorException: Error: Call to undefined function Oly\Date\lang() in D:\xampp\htdocs\laravel4\laravel\vendor\oly\src\Oly\Date\Calendar.php line 152

the language file:

'ago', 'periods' => array('seconds', 'minutes', 'hours', 'days', 'weeks', 'months', 'years', 'decades', 'century'), ); i can use trans('oly::date.periods.1') to "seconds" but i cannot access to 'ago' with trans('oly::date.ago')

@andrewryno
Copy link
Contributor

I was having this (or a similar) problem last night but couldn't figure out how to fix it. Basically when you're in a namespace you define, PHP tries to find the Lang/Config/etc. facades within that namespace. Even if you try to call it using \Lang, \Config, etc. (global namespace), it fails.

@taylorotwell
Copy link
Member

I can't recreate this. Would be helpful to paste your service provider, package directory structure, etc.

@ghost
Copy link
Author
ghost commented Feb 13, 2013

I,m adding

"psr-0": { "": "vendor/oly/src/" }

for loading package
service provider src:

<?php

namespace Oly\Providers;

use Illuminate\Support\ServiceProvider,
    Illuminate\Support\Facades\Config,
    Illuminate\Support\Facades\Validator,
    Oly\Settings\Repository;

class OlyCoreServiceProvider extends ServiceProvider {

        /**
         * Indicates if loading of the provider is deferred.
         *
         * @var bool
         */
        protected $defer = false;

        /**
         * Bootstrap the application events.
         *
         * @return void
         */
        public function boot() {
                $this->package('oly/oly');
                $Settings = new Repository($this->app['env'], Config::get('oly::settings.table'));
                $Date = new \Oly\Date\Repository;
                $this->app->instance('Settings', $Settings);
                $this->app->instance('Date', $Date);
                Validator::resolver(function($translator, $data, $rules) {
                                return new \Oly\Validator\Validator($translator, $data, $rules);
                        });
                include __DIR__ . '/../router.php';
                include __DIR__ . '/../Helpers/helpers.php';
        }

        /**
         * Register the service provider.
         *
         * @return void
         */
        public function register() {

        }

        /**
         * Get the services provided by the provider.
         *
         * @return array
         */
        public function provides() {
                return array();
        }

}

and the package directory structure
├───public
├───src
│ ├───config
│ ├───lang
│ │ ├───en
│ │ └───fa
│ ├───migrations
│ ├───Oly
│ │ ├───Auth
│ │ ├───Controllers
│ │ │ └───Users
│ │ ├───Date
│ │ │ ├───Calendars
│ │ │ └───lang
│ │ ├───Facades
│ │ ├───Helpers
│ │ ├───Providers
│ │ ├───Settings
│ │ └───Validator
│ └───views
└───tests

@taylorotwell
Copy link
Member

It may be because you have created a new "Provider" namespace. Move it back into the directory above that.

@ghost
Copy link
Author
ghost com 8000 mented Feb 16, 2013

tanks I do this but the problem was not solved
I can access the arrays in language files but can't access the 'ago' string

@raftalks
Copy link
Contributor

@sajjad-ser I think your issue is related to this #43

@billmn
Copy link
Contributor
billmn commented Feb 28, 2013

@sajjad-ser Have you solved?

joelharkes added a commit to joelharkes/framework_old that referenced this issue Mar 7, 2019
joelharkes added a commit to joelharkes/framework_old that referenced this issue Mar 7, 2019
Add simple app version setup (on docker build) - Fixes laravel#283
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants
0