TrWithData translate key with template data, it will replace the template data {{ .PlaceHolder }} in the translation.
(lang i18n.Language, key string, templateData any)
| 154 | |
| 155 | // TrWithData translate key with template data, it will replace the template data {{ .PlaceHolder }} in the translation. |
| 156 | func TrWithData(lang i18n.Language, key string, templateData any) string { |
| 157 | if GlobalTrans == nil { |
| 158 | return key |
| 159 | } |
| 160 | translation := GlobalTrans.TrWithData(lang, key, templateData) |
| 161 | if translation == key { |
| 162 | return GlobalTrans.TrWithData(i18n.DefaultLanguage, key, templateData) |
| 163 | } |
| 164 | return translation |
| 165 | } |
| 166 | |
| 167 | // reportTranslatorFormatError re-parses the YAML file to locate the invalid entry |
| 168 | // when go-i18n fails to add the translator. |
no outgoing calls
no test coverage detected