列出特定语言的所有国家

List All the countries in a specific language

我需要用法语列出所有国家。

all_countries = self.env['res.country'].search([])
for country in all_countries:
   _logger.error(country.name)

使用此代码我可以获取乡村英语 Name.How 以获取法语?

据我所知,国家和语言之间没有参考。您必须通过外部模块获取列表。尝试 pycountry (https://pypi.python.org/pypi/pycountry/0.12.1),获取国家代码列表(按语言代码 fr-*),然后在 res.country.

中搜索匹配项

或者您可以覆盖 res.country 并添加您自己的语言参考:)