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

Translation updater: Add support for function call without parantheses #14574

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

srifqi
Copy link
Member

@srifqi srifqi commented Apr 22, 2024

Goal of the PR
This PR adds support for Lua function call without parentheses (single parameter function call).

How does the PR work?
This PR adds two patterns for Lua function call without parentheses, both for "single/double-quote" and for [[multiline]].

Does it resolve any reported issue?
This PR tries to fix #14494.

If not a bug fix, why is this PR needed? What usecases does it solve?
See the linked issue and https://www.lua.org/pil/5.html for informations about single argument call.

To do

This PR is Ready for Review.

How to test

  1. Create a mod with some code using S (and its variants) and without parentheses.
  2. Run the script.
  3. Check that the string exists.
S("Double-quote with parentheses")
S"Double-quote without parentheses"
S('Single-quote with parentheses')
S'Single-quote without parentheses'
S([[Multiline with parentheses]])
S[[Multiline without parentheses]]
S
[[Multiline
without
parentheses]]

@srifqi
Copy link
Member Author

srifqi commented Apr 22, 2024

Note:
The string order in the translation files depends on the way the strings are written:

  1. Single/double-quote with parentheses
  2. Multiline with parentheses
  3. Single/double-quote without parentheses
  4. Multiline without parentheses

I haven't had a success in combining all of those so that the order matches the occurrences in the file.

@srifqi srifqi added @ Startup / Config / Util Feature ✨ PRs that add or enhance a feature labels Apr 22, 2024
@Zughy Zughy added the Supported by core dev Not on the roadmap, yet some core dev decided to take care of this PR label Apr 22, 2024
@SmallJoker
Copy link
Member

Modified devtest/chest/chest.lua

local S = minetest.get_translator("chest")

minetest.register_node("chest:chest", {
	description = S"Chest" .. "\n" ..
		"32 inventory slots",

results in

# textdomain: chest
Chest@n32 inventory slots=

However, only "Chest" should be translated.

@srifqi srifqi force-pushed the tr_lua_special_function_call branch from 894541a to c56ce80 Compare April 27, 2024 07:00
@srifqi
Copy link
Member Author

srifqi commented Apr 27, 2024

I moved matching strings for single parameter call before strings concatenations.

This results in string order change:

  1. Single/double-quote without parentheses
  2. Multiline without parentheses
  3. Single/double-quote with parentheses
  4. Multiline with parentheses

I also rebased this PR.


Ordering strings based on their occurrences in the file will be harder since there are text changes due to string concatenations after matching function call without parentheses and before matching function call with parentheses.

Copy link
Member

@SmallJoker SmallJoker left a comment

Choose a reason for hiding this comment

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

Works

@grorp grorp added the Action / change needed Code still needs changes (PR) / more information requested (Issues) label Apr 30, 2024
Co-authored-by: Lars Mueller <[email protected]>
@appgurueu appgurueu removed the Action / change needed Code still needs changes (PR) / more information requested (Issues) label May 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature ✨ PRs that add or enhance a feature One approval ✅ ◻️ @ Startup / Config / Util Supported by core dev Not on the roadmap, yet some core dev decided to take care of this PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Mod translation updater: S"Hello"-type calls aren't picked up
5 participants