how to find unlocalized strings in flutter/ easy_localization

huangapple go评论97阅读模式
英文:

how to find unlocalized strings in flutter/ easy_localization

问题

最近我们在Flutter中使用easy_localization包完成了一个大型应用程序,但现在我需要检查项目中是否有任何不遵循该包规则并且在不同语言环境下不兼容的字符串?
错误的模式:

"str"
'str'

正确的模式:

tr("str")
tr('str')
英文:

Recently we complete a huge application with easy_localization package in flutter
but now I need to check is there any string in project that dose not follow this package rules and not compatible in different locales?
wrong pattern:

"str"
'str'

correct pattern

tr("str")
tr('str')

答案1

得分: 0

我用以下两个正则表达式解决了这个问题:

[^(]"[^)]
[^(]'[^)]

可以在 regex101 上进行测试和改进。
你可以像这样在 VS Code 中使用它来查找它们:

how to find unlocalized strings in flutter/ easy_localization
如果你知道更好的方法或表达式来解决它,请在评论中告诉我。

英文:

I solved this issue with these two regular expressions:

[^(]".*"[^)]
[^(]'.*'[^)]

that can be tested and improved in regex101
you can use it in vs code like this to find them

how to find unlocalized strings in flutter/ easy_localization
If you know better way or expression to solve it
please inform me at comments

答案2

得分: 0

你可以使用编辑器在项目中搜索与"str"匹配的内容,并自行确认。

我对正则表达式不是很擅长,但我认为这个表达式可以实现:[^(]".*"[^)]

英文:

you can just search your project for anything that matches "str" using your editor and confirm it yourself

I'm not that good at regex but I think this will do it [^(]".*"[^)]

huangapple
  • 本文由 发表于 2023年8月9日 16:32:55
  • 转载请务必保留本文链接:https://go.coder-hub.com/76865935.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定