You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Any, as it refers to inner working of the core library, regardless of any context.
Operating System & Odin Version:
Odin: dev-2024-04-nightly:aab122ede
OS: Linux Mint 21.3, Linux 5.15.0-101-generic
CPU: Intel(R) Core(TM) i5-6400 CPU @ 2.70GHz
RAM: 15913 MiB
Backend: LLVM 17.0.6
Expected Behaviour
In core:text/i18n, procs get_single_section() and get_by_section() are documented to default to a singular case when no plural number is provided (see for instance get_section_single_section().
Current Behaviour
They, rather, default to a 'none' plural number (0). Unless a specific pluraliser is used, the 'none' case is (correctly for a default) typically treated as a plural. So, defaulting the number parameter to 0 generically results in a plural form being chosen if available. Note that the number parameter refers to the amount of 'things' being considered in the message, not to the index of the translation slot (which indeed is usually 0 for the singular form).
Failure Information (for bugs)
There is no failure, rather the wrong message is typically returned, if plural forms are available.
Steps to Reproduce
compile the attached main.odin source file (in the i18n_bug.zip file: github filters out most file extensions)
place in the same directory the attached sample.mo file and the compiled executable and run it
output:
This is message 1 - plural
This is message 1 - plural
While the expected output is
This is message 1
This is message 1 - plural
which is obtained if the number default values in the aforementioned procs are changed to 1.
For completeness, this is the main.odin source:
package i18n_bug
import "core:fmt"
import "core:path/filepath"
import "core:os"
import "core:strings"
import "core:text/i18n"
main :: proc()
{
// build the path of a message catalogue parallel to the executable
app_path: = os.args[0]
cat_path: = strings.join({filepath.dir(app_path), "sample.mo"}, "/")
defer delete(cat_path)
// parse and load the message catalogue without any specific pluraliser
i18n_err: i18n.Error
i18n.ACTIVE, i18n_err = i18n.parse_mo_file(cat_path)
if (i18n_err == i18n.Error.None || i18n_err == nil)
{
defer i18n.destroy(i18n.ACTIVE)
// The "Message1" is pluralised in the catalogue
fmt.println(i18n.get("Message1")) // no number: shall return the singular form
fmt.println(i18n.get("Message1", 2)) // a plural number: shall return the plural form
}
else do fmt.println("Error parsing message catalogue:", i18n_err)
}
The attached sample.mo file has been obtained by compiling with POEdit the following sample.po file:
Context
Any, as it refers to inner working of the core library, regardless of any context.
Expected Behaviour
In
core:text/i18n
, procsget_single_section()
andget_by_section()
are documented to default to a singular case when no plural number is provided (see for instance get_section_single_section().Current Behaviour
They, rather, default to a 'none' plural number (
0
). Unless a specific pluraliser is used, the 'none' case is (correctly for a default) typically treated as a plural. So, defaulting thenumber
parameter to0
generically results in a plural form being chosen if available. Note that thenumber
parameter refers to the amount of 'things' being considered in the message, not to the index of the translation slot (which indeed is usually 0 for the singular form).Failure Information (for bugs)
There is no failure, rather the wrong message is typically returned, if plural forms are available.
Steps to Reproduce
main.odin
source file (in thei18n_bug.zip
file: github filters out most file extensions)sample.mo
file and the compiled executable and run itWhile the expected output is
which is obtained if the
number
default values in the aforementioned procs are changed to1
.For completeness, this is the
main.odin
source:The attached
sample.mo
file has been obtained by compiling withPOEdit
the followingsample.po
file:i18n_bug.zip
The text was updated successfully, but these errors were encountered: