Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SRO] Organize DM-l10n strings #2491

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions libs/sr/dm-localization/src/executors/gen-locale/executor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,17 @@ const runExecutor: PromiseExecutor<GenLocaleExecutorSchema> = async (
//general manual localization namespaces
if (
[
'characters',
'charNames',
'common',
'lightCones',
'lightConeNames',
'relics',
'relicNames',
'sheet',
'slotKey',
'paths',
'statKey',
'teams',
'ui',
].includes(type)
)
return dumpFile(`${fileDir}/${type}_gen.json`, typeData)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
avatarSkillTreeConfig,
characterIdMap,
} from '@genshin-optimizer/sr/dm'
import { convertToHash } from './util'
import { convertToHash } from '../util'

type CharData = {
name: string
Expand Down Expand Up @@ -128,4 +128,4 @@ const charArray = Object.entries(avatarConfig).map(([charId, charConfig]) => {

const data = Object.fromEntries(charArray)
verifyObjKeys(data, allCharacterDataKeys)
export const charHashData = data
export const allCharHashData = data
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If there are better name/organization suggestions from what I've done in this commit (move all related files into related folders and rename the original files generating all chars/LCs/relics + their data into terms that possibly better indicate that they're for 'generating all assets for a category'), please let me know.

Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
export const sheetHashData = {
export const charHashData = {
label: {
one: '-1435714104', // Character
many: '-676993900', // Characters
},
eidolonLvl: '1102721995', // "Eidolon Level:"
traces: '1252031000',
type: {
physical: '-1101149179',
quantum: '88513016',
Expand All @@ -8,15 +14,6 @@ export const sheetHashData = {
fire: '-1474263915',
imaginary: '118034640',
},
path: {
Erudition: '-953720572',
Preservation: '-1357005099',
Abundance: '1371878256',
Nihility: '-1760289626',
Destruction: '209078842',
Harmony: '-194205685',
TheHunt: '612363369',
},
ability: {
basic: '216145179',
skill: '216145178',
Expand All @@ -32,7 +29,4 @@ export const sheetHashData = {
support: '1560729279',
impair: '397929865',
},
eidolonLvl: '1102721995', //"Eidolon Level:"
lvl: '982642653', //"Lv."
superimpose: '-2008197403', //"Superimposition"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from './allCharacters'
export * from './character'
60 changes: 42 additions & 18 deletions libs/sr/dm-localization/src/executors/gen-locale/lib/hashData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,47 +4,71 @@ import {
allLightConeKeys,
allRelicSetKeys,
} from '@genshin-optimizer/sr/consts'
import { charHashData } from './charHashData'
import { lightConeHashData } from './lightConeHashData'
import { relicHashData } from './relicHashData'
import { sheetHashData } from './sheetHashData'
import { allCharHashData, charHashData } from './charHashData'
import { allLightConeHashData, lightConeHashData } from './lightConeHashData'
import { allRelicHashData, relicHashData } from './relicHashData'
import { uiHashData } from './uiHashData'

export type LanguageData = typeof HashData

const charNames = Object.fromEntries(
Object.entries(charHashData).map(([key, data]) => [key, data.name])
Object.entries(allCharHashData).map(([key, data]) => [key, data.name])
)
verifyObjKeys(charNames, allCharacterDataKeys)

const relicNames = Object.fromEntries(
Object.entries(relicHashData).map(([key, data]) => [key, data.setName])
Object.entries(allRelicHashData).map(([key, data]) => [key, data.setName])
)
verifyObjKeys(relicNames, allRelicSetKeys)

const lightConeNames = Object.fromEntries(
Object.entries(lightConeHashData).map(([key, data]) => [key, data.name])
Object.entries(allLightConeHashData).map(([key, data]) => [key, data.name])
)
verifyObjKeys(lightConeNames, allLightConeKeys)

export const HashData = {
char: charHashData,
char: allCharHashData,
charNames,
characters: charHashData,

relic: relicHashData,
relic: allRelicHashData,
relicNames,
relics: relicHashData,

lightCone: lightConeHashData,
lightCone: allLightConeHashData,
lightConeNames,
lightCones: lightConeHashData,

sheet: sheetHashData,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One of the reason why we have separated namespace -> separated .JSON is that translations are usually lazy loaded. when the artifact page is loaded, it doesn't need any of the character/team UI translations, and vice versa. This can impact load time of pages and elements, since most of our elements are behind loading barriers and suspenses. we can designate some of the namespace to be permanently loaded(i think "ui" is).

Copy link
Collaborator Author

@tiffanynwyeung tiffanynwyeung Oct 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's understandable, and in this commit I split up a lot more of the namespaces in light of this information. Though, it also means I'm not quite sure where to put some of these smaller namespaces (e.g. common, team, paths, statKey) or what the file should be (miscHashData perhaps?).

slotKey: {
head: '1826268247',
hands: '-2144127003',
body: '1799740313',
feet: '1154536283',
sphere: '1873322474',
rope: '74129613',
ui: uiHashData,

common: {
level: '-636045037', // Level
lv: '982642653', // Lv.
rarity: '1898197464',
},

teams: {
label: '-839489437', // Team
name: '858715661', // Team Name
editTeam: '-756448810',
},

paths: {
label: {
one: '-1952347303', // Path
many: '-815380608', // Paths
},
pathKey: {
Erudition: '-953720572',
Preservation: '-1357005099',
Abundance: '1371878256',
Nihility: '-1760289626',
Destruction: '209078842',
Harmony: '-194205685',
TheHunt: '612363369',
},
},

statKey: {
spd: '461357812',
spd_: '461357812',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,4 @@ const lightConeArray = Object.entries(equipmentConfig).map(
const data = Object.fromEntries(lightConeArray)
verifyObjKeys(data, allLightConeKeys)

export const lightConeHashData = data
export const allLightConeHashData = data
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from './allLightCones'
export * from './lightCone'
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export const lightConeHashData = {
label: {
one: '-514739711', // Light Cone
many: '582917607', // Light Cones
},
superimposition: '-2008197403',
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
relicSetIdMap,
relicSetSkillConfig,
} from '@genshin-optimizer/sr/dm'
import { convertToHash } from './util'
import { convertToHash } from '../util'

type RelicData = {
setName: string
Expand Down Expand Up @@ -43,4 +43,4 @@ const relicArray = Object.entries(relicSetConfig).map(([setId, setConfig]) => {

const data = Object.fromEntries(relicArray)
verifyObjKeys(data, allRelicSetKeys)
export const relicHashData = data
export const allRelicHashData = data
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from './allRelics'
export * from './relic'
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
export const relicHashData = {
label: '-1823495414', // Relics
set: '1604210092',
mainStat: '-338586359',
slot: '-1409515362',
slotKey: {
head: '1826268247',
hands: '-2144127003',
body: '1799740313',
feet: '1154536283',
sphere: '1873322474',
rope: '74129613',
},
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ export type InterpolationTag = keyof typeof interpolationTags
// Process tags in string to template for i18n
function processString(str: string | undefined) {
if (str === undefined) str = ''

// Remove '{SPACE}' artifacts from certain strings
// Do this first to match curly brackets to prevent interfering with later str replacements
str = str.replace(/(.*?){SPACE}/g, '$1')
Copy link
Collaborator Author

@tiffanynwyeung tiffanynwyeung Oct 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Certain strings will contain {SPACE} at the end, so this is just an exact match to strip it out. This shouldn't conflict with any of the other matching/processing we're doing.

// Find portion similar to
// <color=#f29e38ff><unbreak>#1[i]%</unbreak></color>
// replaces with '<color=#f29e38ff>#1[i]%</color>'
Expand Down
50 changes: 50 additions & 0 deletions libs/sr/dm-localization/src/executors/gen-locale/lib/uiHashData.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
export const uiHashData = {
confirm: '35141102',
cancel: '-923369432',

open: '554533651',
close: '-316424440',

edit: '71676923',
preview: '1494310683',
save: '922770375',
delete: '1854908959',
clear: '-644581385',
reset: '1035909461',

add: '627092858',
remove: '1045883501',

locked: '936395545',
unlocked: '2032806954',
lockAll: '1539252863',
unlockAll: '-26831078',

excluded: '-1904552378',
includeSelected: '1476839551',
excludeSelected: '-1093811249',

activated: '-1242210091',
notActivated: '-732278832',

equipped: '1791115444',
unequipped: '-202463180',
currentlyEquipped: '1354485618',
notEquipped: '961141924',

equip: '-1174264395',
switch: '310431922',
compare: '111565860',

search: '1781769983',
filter: '-1811155248',
empty: '681643565',

inventory: '888911468',
settings: '-1818257148',

gender: {
F: '732414811',
M: '1491929698',
},
}
Loading