1
0
forked from baron/baron-sso

userfront i18n placeholder 치환과 번역 렌더링 오류 수정

This commit is contained in:
2026-04-06 17:48:07 +09:00
parent beae6bb4b1
commit d086b7ea3c
4 changed files with 88 additions and 30 deletions

View File

@@ -55,6 +55,18 @@ class _DashboardScreenState extends ConsumerState<DashboardScreen> {
bool _showAllActivities = false;
final Set<String> _revokedClientIds = {};
String _renderTranslatedText(
String key, {
String? fallback,
Map<String, String> values = const {},
}) {
var text = tr(key, fallback: fallback);
values.forEach((name, value) {
text = text.replaceAll('{{$name}}', value).replaceAll('{$name}', value);
});
return text;
}
@override
void initState() {
super.initState();
@@ -700,10 +712,10 @@ class _DashboardScreenState extends ConsumerState<DashboardScreen> {
final clientId = log.clientId;
final tooltip = clientId.isEmpty
? tr('msg.userfront.dashboard.client_id_missing')
: tr(
: _renderTranslatedText(
'msg.userfront.dashboard.client_id',
fallback: 'Client ID: {{id}}',
params: {'id': clientId},
values: {'id': clientId},
);
final baseStyle = style ?? const TextStyle();
final emphasisStyle = clientId.isEmpty
@@ -891,7 +903,11 @@ class _DashboardScreenState extends ConsumerState<DashboardScreen> {
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
tr('msg.userfront.greeting', params: {'name': userName}),
_renderTranslatedText(
'msg.userfront.greeting',
fallback: 'Hello, {{name}}.',
values: {'name': userName},
),
style: const TextStyle(
fontSize: 22,
fontWeight: FontWeight.bold,
@@ -1122,18 +1138,18 @@ class _DashboardScreenState extends ConsumerState<DashboardScreen> {
const SizedBox(height: 12),
if (browserLabel.isNotEmpty)
Text(
tr(
_renderTranslatedText(
'msg.userfront.dashboard.sessions.browser',
params: {'value': browserLabel},
values: {'value': browserLabel},
),
style: TextStyle(fontSize: 13, color: Colors.grey[700]),
),
if (osLabel.isNotEmpty) ...[
const SizedBox(height: 4),
Text(
tr(
_renderTranslatedText(
'msg.userfront.dashboard.sessions.os',
params: {'value': osLabel},
values: {'value': osLabel},
),
style: TextStyle(fontSize: 13, color: Colors.grey[700]),
),
@@ -1142,18 +1158,20 @@ class _DashboardScreenState extends ConsumerState<DashboardScreen> {
if (session.clientId.trim().isNotEmpty) ...[
const SizedBox(height: 6),
Text(
tr(
_renderTranslatedText(
'msg.userfront.dashboard.client_id',
params: {'id': session.clientId},
fallback: 'Client ID: {{id}}',
values: {'id': session.clientId},
),
style: TextStyle(fontSize: 12, color: Colors.grey[600]),
),
],
const SizedBox(height: 8),
Text(
tr(
_renderTranslatedText(
'msg.userfront.dashboard.sessions.session_id',
params: {'id': _compactSessionId(session.sessionId)},
fallback: 'Session ID: {{id}}',
values: {'id': _compactSessionId(session.sessionId)},
),
style: TextStyle(fontSize: 12, color: Colors.grey[600]),
),
@@ -1956,10 +1974,10 @@ class _DashboardScreenState extends ConsumerState<DashboardScreen> {
),
const SizedBox(height: 6),
_selectableText(
tr(
_renderTranslatedText(
'msg.userfront.audit.session_id',
fallback: 'Session ID: {{value}}',
params: {
values: {
'value': log.sessionId.isEmpty
? tr('ui.common.hyphen', fallback: '-')
: log.sessionId,