Skip to content

Conversation

@MishimaHaruna
Copy link
Member

@MishimaHaruna MishimaHaruna commented May 15, 2016

Hercules Ultimate Localization Design

  • Fixes issues with nested function calls and the HULD template generator
  • Improves the quality of the generated translation strings, allowing for some sentence structure variations (see below)
  • Adds an option to let server administrators decide whether to hard-wrap or soft-wrap their scripts (see below)

Some highlights:

Added option to strip hard line-breaks from mes dialogs

  • The \r character, in a mes dialog, is normally represented by the client as a hard line-break.
  • Since a client may have different requirements in line lengths (for example using a font with different size or metrics), an user might wish to ignore hard-wraps and let the client automatically soft-wrap
    instead.
  • If you want to hard-wrap (official default), keep the SCRIPT_MES_STRIP_LINEBREAK define commented out.
  • If you want to let the client soft-wrap automatically (may work better for custom clients), uncomment it.
  • Imprved HULD handling of \r (to avoid control characters in the generated file)
  • Please note that this requires cooperation by script writers:
    • Each mes should contain one and only one sentence, possibly without using the '+' concatenation (but, rather, sprintf).
    • Two separate sentences (where a hard-wrap is required even for soft-wrapped text) should always go into separate mes commands.
    • Following the above two recommendations, also produces a better quality translations .pot file.

Proof-of-concept best scripting practices for HULD

  • Note: This only edits one script (Parmy Gianino of the Alchemist quest), and it's an invitation to script developers to gradually update the other scripts following the same guidelines.
  • mes strings are split by sentences: each string contains one and only one sentence. Line-break hints are specified with \r (and for readability the string is split in multiple lines with parse-time concatenation, without using the '+' operator)
  • When sentences need concatenation (variable names or values), sprintf or mesf are used, so that the generated translatable string is still one and only one. When using sprintf, the _() or _$() macros are used, to mark the string as translatable. For format strings, use _$() and for normal strings use _(). When using mesf, no additional action is necessary.
  • select() / prompt() entries are in separate entries, separated by commas, where possible (it makes their translation easier)
  • This makes it easier to translate NPCs to languages with different sentence ordering (and with longer or shorter sentences). In the generated .pot, sentecnes will no longer span across several strings.
  • Replaced hardcoded item names with getitemname()

@MishimaHaruna MishimaHaruna added status:inprogress Issue is being worked on / the pull request is still a WIP type:enhancement Issue describes an enhancement or feature that should be implemented status:code-review Awaiting code review component:core:scriptengine Affecting the script engine or the script commands and removed status:inprogress Issue is being worked on / the pull request is still a WIP labels May 15, 2016
@MishimaHaruna MishimaHaruna modified the milestone: Architecture May 15, 2016
@MishimaHaruna MishimaHaruna added status:inprogress Issue is being worked on / the pull request is still a WIP and removed status:code-review Awaiting code review labels May 15, 2016
@ghost
Copy link

ghost commented May 17, 2016

THANKS GOD -

@ghost
Copy link

ghost commented May 18, 2016

will it allow us to translate npc display names as well? 😍

@dastgirp
Copy link
Member

Not yet @EPuncker, you cannot change display name yet..

@MishimaHaruna
Copy link
Member Author

Good point about the NPC display names. We can do something about it, but there will be limitations:

  • The command setnpcdisplay() would invalidate the translations. If a script uses that to change a NPC name, the name would be set the same for every language, without translations.
  • If we want the NPC names to use the per-player language settings (instead of the global server-wide language setting), there are some packets that would become less efficient. This needs some further research.
  • Commands such as donpcevent() or enablenpc() would still use the original name, not the translated one (not really a limitation, more like a design decision to keep things sane).
  • Whispering (NPC:Npcname) to trigger OnWhisperGlobal would still require the original name, not the translated one.

@ghost
Copy link

ghost commented May 24, 2016

already going to buy poedit pro in order to full translate my server 😍 I'm so excited lol

@MishimaHaruna MishimaHaruna force-pushed the huld-improvements branch 2 times, most recently from 9266ed4 to 02f0cb3 Compare June 18, 2016 00:54
- Clears a VECTOR, without freeing its data (truncates length,
  preserving capacity)

Signed-off-by: Haru <[email protected]>
- Fixes various signed/unsigned comparisons.

Signed-off-by: Haru <[email protected]>
- Fixes various signed/unsigned comparisons.

Signed-off-by: Haru <[email protected]>
- Fixes various signed/unsigned comparisons.

Signed-off-by: Haru <[email protected]>
Signed-off-by: Haru <[email protected]>
- The generated translation file now loads cleanly without encoding conversion errors

Signed-off-by: Haru <[email protected]>
- The function now checks its arguments, rather than passing them to
  the system implementation (safer against arbitrary memory access or
  wrong variable type)
- Implemented positional ('%1$d') specifiers (POSIX style)
- See script_commands.txt for details about the supported format
  specifiers.

Signed-off-by: Haru <[email protected]>
…ity)

- parse_simpleexpr_paren()
- parse_simpleexpr_number()
- parse_simplexpr_string()
- parse_simpleexpr_name()

Signed-off-by: Haru <[email protected]>
Signed-off-by: Haru <[email protected]>
- The `\r` character, in a `mes` dialog, is normally represented by the
  client as a hard line-break.
- Since a client may have different requirements in line lengths (for
  example using a font with different size or metrics), an user might
  wish to ignore hard-wraps and let the client automatically soft-wrap
  instead.
- If you want to hard-wrap (official default), keep the
  SCRIPT_MES_STRIP_LINEBREAK define commented out.
- If you want to let the client soft-wrap automatically (may work better
  for custom clients), uncomment it.
- Imprved HULD handling of `\r` (to avoid control characters in the
  generated file)
- Please note that this requires cooperation by script writers:
  * Each `mes` should contain one and only one sentence, possibly
    without using the '+' concatenation (but, rather, sprintf).
  * Two separate sentences (where a hard-wrap is required even for
    soft-wrapped text) should always go into separate `mes` commands.
  * Following the above two recommendations, also produces a better
    quality translations .pot file.

Signed-off-by: Haru <[email protected]>
…s format string

- Strings passed to sprintf should use the _$() macro instead of _(), to
  generate the .pot translation template with a directive to correctly
  handle the % sign.
- Strings passed through _() are instead explicitly marked as regular
  (non format) strings if they contain '%'.

Signed-off-by: Haru <[email protected]>
- `mes` strings are split by sentences: each string contains one and
  only one sentence. Line-break hints are specified with \r (and for
  readability the string is split in multiple lines with parse-time
  concatenation, without using the '+' operator)
- When sentences need concatenation (variable names or values), sprintf
  is used, so that the generated translatable string is still one and
  only one. The `_()` macro is used inside sprintf, to mark the string
  as translatable.
- `select()` / `prompt()` entries are in separate entries, separated by
  commas, where possible (it makes their translation easier)
- This makes it easier to translate NPCs to languages with different
  sentence ordering (and with longer or shorter sentences). In the
  generated .pot, sentecnes will no longer span across several strings.

Only the npc/jobs/2-2/alchemist.txt script was modified, as a proof of
concept.

Signed-off-by: Haru <[email protected]>
- Replaced hardcoded item names with getitemname()

Only the npc/jobs/2-2/alchemist.txt script was modified, as a proof of
concept.

Signed-off-by: Haru <[email protected]>
The script->get_translation_file_name() is more robust (and actually
works) now.

Signed-off-by: Haru <[email protected]>
@MishimaHaruna MishimaHaruna added status:code-review Awaiting code review and removed status:inprogress Issue is being worked on / the pull request is still a WIP labels Jun 25, 2016
@4144 4144 merged commit 5f4c452 into master Jun 25, 2016
@MishimaHaruna MishimaHaruna removed the status:code-review Awaiting code review label Jun 25, 2016
@MishimaHaruna MishimaHaruna deleted the huld-improvements branch June 25, 2016 22:47
@botka4aet
Copy link

I added generate-translations and map-server restarts after fully loaded.

@Cyanide0210
Copy link
Contributor

Cyanide0210 commented Jan 19, 2019

@botka4aet just move generated-translations.so out from plugins folder but I guess you figured it out by now.

Just leaving a comment for reference.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component:core:scriptengine Affecting the script engine or the script commands type:enhancement Issue describes an enhancement or feature that should be implemented

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants