feat(i18n): display only active language in translation fields
Update TranslationFields to render a single input for the current locale Ensure entity base names fallback to the active locale translation on save
This commit is contained in:
@@ -16,7 +16,7 @@ type SkillItemDropForm = {
|
||||
|
||||
const route = useRoute();
|
||||
const router = useRouter();
|
||||
const { t } = useI18n();
|
||||
const { locale, t } = useI18n();
|
||||
const options = ref<Options | null>(null);
|
||||
const itemOptions = ref<NamedEntity[]>([]);
|
||||
const languages = ref<Language[]>([]);
|
||||
@@ -87,6 +87,15 @@ function skillDropLabel(skillId: string) {
|
||||
return name ? t('pages.pokemon.skillDrop', { name }) : t('pages.pokemon.dropItem');
|
||||
}
|
||||
|
||||
function pokemonNameForSave() {
|
||||
const baseName = pokemonForm.value.name.trim();
|
||||
if (baseName !== '') {
|
||||
return pokemonForm.value.name;
|
||||
}
|
||||
|
||||
return pokemonForm.value.translations[String(locale.value || '')]?.name ?? '';
|
||||
}
|
||||
|
||||
function closeEditor() {
|
||||
void router.push(cancelTo.value);
|
||||
}
|
||||
@@ -164,7 +173,7 @@ async function savePokemon() {
|
||||
try {
|
||||
const payload: PokemonPayload = {
|
||||
id: Number(isEditing.value ? routeId.value : pokemonForm.value.id),
|
||||
name: pokemonForm.value.name,
|
||||
name: pokemonNameForSave(),
|
||||
translations: pokemonForm.value.translations,
|
||||
environmentId: Number(pokemonForm.value.environmentId),
|
||||
skillIds: toIds(pokemonForm.value.skillIds.slice(0, 2)),
|
||||
|
||||
Reference in New Issue
Block a user