PHP Class Waavi\Translation\Repositories\TranslationRepository

Inheritance: extends Waavi\Translation\Repositories\Repository
Afficher le fichier Open project: waavi/translation Class Usage Examples

Protected Properties

Свойство Type Description
$database Illuminate\Database\Connection
$errors Illuminate\Support\MessageBag @var \Illuminate\Support\MessageBag
$model Waavi\Translation\Models\Translation The model being queried.
$validator Illuminate\Validation\Validator @var \Illuminate\Validation\Validator

Méthodes publiques

Méthode Description
__construct ( Waavi\Translation\Models\Translation $model, Illuminate\Foundation\Application $app ) : void Constructor
allByLocale ( string $locale, $perPage ) : Waavi\Translation\Models\Translation Return a list of translations for the given language. If perPage is > 0 a paginated list is returned with perPage items per page.
create ( array $attributes ) : boolean Insert a new translation into the database.
delete ( integer $id ) : boolean Delete a translation. If the translation is of the default language, delete all translations with the same namespace, group and item
deleteByCode ( string $code ) : boolean Delete all entries by code
findByCode ( string $locale, string $namespace, string $group, string $item ) : Waavi\Translation\Models\Translation Find a translation per namespace, group and item values
findByLangCode ( string $locale, $code ) : Waavi\Translation\Models\Translation Find a translation per namespace, group and item values
flagAsReviewed ( integer $id ) : boolean Flag the entry with the given id as reviewed.
flagAsUnstable ( $namespace, $group, $item ) : boolean Flag all entries with the given namespace, group and item and locale other than default as pending review.
getItems ( string $locale, string $namespace, string $group ) : array Return all items for a given locale, namespace and group
loadArray ( array $lines, string $locale, string $group, string $namespace = '*' ) : void Loads a localization array from a localization file into the databas.
loadSource ( string $locale, string $namespace, string $group ) : array Return all items formatted as if coming from a PHP language file.
parseCode ( string $code ) : boolean Parse a translation code into its components
pendingReview ( string $locale, integer $perPage ) : Waavi\Translation\Models\Translation Retrieve translations pending review for the given locale.
randomUntranslated ( string $locale ) : Waavi\Translation\Models\Translation Find a random entry that is present in the default locale but not in the given one.
search ( string $locale, string $partialCode, integer $perPage ) : Waavi\Translation\Models\Translation Search for entries given a partial code and a locale
translateText ( string $text, string $textLocale, string $targetLocale ) : array Check if there are existing translations for the given text in the given locale for the target locale.
untranslated ( string $locale, integer $perPage, string $text = null ) : Collection List all entries in the default locale that do not exist for the target locale.
update ( $id, $text ) : boolean Update a translation.
updateAndLock ( $id, $text ) : boolean Update and lock translation. Locked translations will not be ovewritten when loading translation files into the database.
updateDefaultByCode ( string $code, string $text ) : boolean Insert or Update entry by translation code for the default locale.
validate ( array $attributes ) : boolean Validate the given attributes
validationErrors ( ) : Illuminate\Support\MessageBag Returns the validations errors of the last action executed.

Méthodes protégées

Méthode Description
untranslatedQuery ( string $locale ) : Builder Create and return a new query to identify untranslated records.

Method Details

__construct() public méthode

@param \Waavi\Translation\Models\Translation $model Bade model for queries.
public __construct ( Waavi\Translation\Models\Translation $model, Illuminate\Foundation\Application $app ) : void
$model Waavi\Translation\Models\Translation
$app Illuminate\Foundation\Application
Résultat void

allByLocale() public méthode

@param string $locale
public allByLocale ( string $locale, $perPage ) : Waavi\Translation\Models\Translation
$locale string
Résultat Waavi\Translation\Models\Translation

create() public méthode

If the attributes are not valid, a null response is given and the errors can be retrieved through validationErrors()
public create ( array $attributes ) : boolean
$attributes array Model attributes @return boolean
Résultat boolean

delete() public méthode

@param integer $id
public delete ( integer $id ) : boolean
$id integer
Résultat boolean

deleteByCode() public méthode

@param string $code
public deleteByCode ( string $code ) : boolean
$code string
Résultat boolean

findByCode() public méthode

@param string $locale
public findByCode ( string $locale, string $namespace, string $group, string $item ) : Waavi\Translation\Models\Translation
$locale string
$namespace string @param string $group @param string $item @return Translation
$group string
$item string
Résultat Waavi\Translation\Models\Translation

findByLangCode() public méthode

@param string $locale
public findByLangCode ( string $locale, $code ) : Waavi\Translation\Models\Translation
$locale string
Résultat Waavi\Translation\Models\Translation

flagAsReviewed() public méthode

@param integer $id
public flagAsReviewed ( integer $id ) : boolean
$id integer
Résultat boolean

flagAsUnstable() public méthode

This is used when an entry for the default locale is updated.
public flagAsUnstable ( $namespace, $group, $item ) : boolean
Résultat boolean

getItems() public méthode

@param string $locale
public getItems ( string $locale, string $namespace, string $group ) : array
$locale string
$namespace string @param string $group @return array
$group string
Résultat array

loadArray() public méthode

@param array $lines
public loadArray ( array $lines, string $locale, string $group, string $namespace = '*' ) : void
$lines array
$locale string @param string $group @param string $namespace @return void
$group string
$namespace string
Résultat void

loadSource() public méthode

@param string $locale
public loadSource ( string $locale, string $namespace, string $group ) : array
$locale string
$namespace string @param string $group @return array
$group string
Résultat array

parseCode() public méthode

@param string $code
public parseCode ( string $code ) : boolean
$code string
Résultat boolean

pendingReview() public méthode

@param string $locale
public pendingReview ( string $locale, integer $perPage ) : Waavi\Translation\Models\Translation
$locale string
$perPage integer Number of elements per page. 0 if all are wanted. @return Translation
Résultat Waavi\Translation\Models\Translation

randomUntranslated() public méthode

@param string $locale Locale to translate to.
public randomUntranslated ( string $locale ) : Waavi\Translation\Models\Translation
$locale string
Résultat Waavi\Translation\Models\Translation

translateText() public méthode

@param string $text
public translateText ( string $text, string $textLocale, string $targetLocale ) : array
$text string
$textLocale string @param string $targetLocale @return array
$targetLocale string
Résultat array

untranslated() public méthode

@param string $locale Language to translate to.
public untranslated ( string $locale, integer $perPage, string $text = null ) : Collection
$locale string
$perPage integer If greater than zero, return a paginated list with $perPage items per page. @param string $text [optional] Show only entries with the given text in them in the reference language. @return Collection
$text string
Résultat Collection

untranslatedQuery() protected méthode

Create and return a new query to identify untranslated records.
protected untranslatedQuery ( string $locale ) : Builder
$locale string
Résultat Illuminate\Database\Query\Builder

update() public méthode

If the translation is locked, no update will be made.
public update ( $id, $text ) : boolean
Résultat boolean

updateAndLock() public méthode

This will force and update if the translation is locked. If the attributes are not valid, a null response is given and the errors can be retrieved through validationErrors()
public updateAndLock ( $id, $text ) : boolean
Résultat boolean

updateDefaultByCode() public méthode

@param string $code
public updateDefaultByCode ( string $code, string $text ) : boolean
$code string
$text string @return boolean
Résultat boolean

validate() public méthode

@param array $attributes
public validate ( array $attributes ) : boolean
$attributes array
Résultat boolean

validationErrors() public méthode

@return \Illuminate\Support\MessageBag
public validationErrors ( ) : Illuminate\Support\MessageBag
Résultat Illuminate\Support\MessageBag

Property Details

$database protected_oe property

protected Connection,Illuminate\Database $database
Résultat Illuminate\Database\Connection

$errors protected_oe property

@var \Illuminate\Support\MessageBag
protected MessageBag,Illuminate\Support $errors
Résultat Illuminate\Support\MessageBag

$model protected_oe property

The model being queried.
protected Translation,Waavi\Translation\Models $model
Résultat Waavi\Translation\Models\Translation

$validator protected_oe property

@var \Illuminate\Validation\Validator
protected Validator,Illuminate\Validation $validator
Résultat Illuminate\Validation\Validator