我如何从这个类数组中检索带有国家代码的翻译,并在我的blade文件中显示它?假设我有国家代码AF,那么我如何返回阿富汗?
class TranslatedCountryCodes
{
private $translatedCodes = [];
private static $instance;
protected function __construct()
{
$this->translatedCodes = [
'AF' => __('Afghanistan', 'countrycode', 'myproject'),
'AX' => __('Aland Islands', 'countrycode', 'myproject')
];
}
public function commitTranslation()
{
return $this->translatedCodes;
}
/**
* @return static
*/
public static function getInstance()
{
if (is_null(static::$instance)) {
static::$instance = new static();
}
return static::$instance;
}
}
我试过了
TranslatedCountryCodes::commitTranslation('AF')
我一直在查找一些辅助函数,但无法找到
1条答案
按热度按时间2lpgd9681#
您可以: