Conditions | 6 |
Paths | 8 |
Total Lines | 28 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
19 | public function get(string $string, string $locale = null) |
||
20 | { |
||
21 | $locale = $locale ?: App::getLocale(); |
||
22 | |||
23 | if ($locale == config('presspack.default_locale')) { |
||
24 | return $string; |
||
25 | } |
||
26 | |||
27 | $table = $this->where('name', md5($string)) |
||
28 | ->where('context', 'presspack') |
||
29 | ->first(); |
||
30 | |||
31 | if (! $table) { |
||
32 | $this->addString($string); |
||
33 | |||
34 | return $string; |
||
35 | } |
||
36 | |||
37 | $translation = $table->translations |
||
38 | ->where('language', $locale) |
||
39 | ->first(); |
||
40 | |||
41 | if (isset($translation->value) && 10 == $translation->status) { |
||
42 | return $translation->value; |
||
43 | } |
||
44 | |||
45 | return $string; |
||
46 | } |
||
47 | |||
63 |