Refactor Windows error message for easier translation
authorPeter Eisentraut <[email protected]>
Thu, 4 Feb 2021 12:31:13 +0000 (13:31 +0100)
committerPeter Eisentraut <[email protected]>
Thu, 4 Feb 2021 12:31:13 +0000 (13:31 +0100)
In the error messages referring to the user right "Lock pages in
memory", this is a term from the Windows OS, so it should be
translated in accordance with the OS localization.  Refactor the error
messages so this is easier and clearer.  Also fix the capitalization
to match the existing capitalization in the OS.

doc/src/sgml/config.sgml
src/backend/port/win32_shmem.c

index e17cdcc8167e8102ca624bf1f951209260bc77a9..5ef1c7ad3c53ea0e40d5f161ad912427fd6054b8 100644 (file)
@@ -1593,14 +1593,14 @@ include_dir 'conf.d'
 
        <para>
         Huge pages are known as large pages on Windows.  To use them, you need to
-        assign the user right Lock Pages in Memory to the Windows user account
+        assign the user right <quote>Lock pages in memory</quote> to the Windows user account
         that runs <productname>PostgreSQL</productname>.
         You can use Windows Group Policy tool (gpedit.msc) to assign the user right
-        Lock Pages in Memory.
+        <quote>Lock pages in memory</quote>.
         To start the database server on the command prompt as a standalone process,
         not as a Windows service, the command prompt must be run as an administrator or
         User Access Control (UAC) must be disabled. When the UAC is enabled, the normal
-        command prompt revokes the user right Lock Pages in Memory when started.
+        command prompt revokes the user right <quote>Lock pages in memory</quote> when started.
        </para>
 
        <para>
index 177315f238d07e635e0d581c07e0b36dd8223700..ab2534351d7c5000e09ff6e08fa60c8eabb226d6 100644 (file)
@@ -141,7 +141,10 @@ EnableLockPagesPrivilege(int elevel)
    if (!OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken))
    {
        ereport(elevel,
-               (errmsg("could not enable Lock Pages in Memory user right: error code %lu", GetLastError()),
+               (errmsg("could not enable user right \"%s\": error code %lu",
+                       /* translator: This is a term from Windows and should be translated to match the Windows localization. */
+                       _("Lock pages in memory"),
+                       GetLastError()),
                 errdetail("Failed system call was %s.", "OpenProcessToken")));
        return FALSE;
    }
@@ -149,7 +152,7 @@ EnableLockPagesPrivilege(int elevel)
    if (!LookupPrivilegeValue(NULL, SE_LOCK_MEMORY_NAME, &luid))
    {
        ereport(elevel,
-               (errmsg("could not enable Lock Pages in Memory user right: error code %lu", GetLastError()),
+               (errmsg("could not enable user right \"%s\": error code %lu", _("Lock pages in memory"), GetLastError()),
                 errdetail("Failed system call was %s.", "LookupPrivilegeValue")));
        CloseHandle(hToken);
        return FALSE;
@@ -161,7 +164,7 @@ EnableLockPagesPrivilege(int elevel)
    if (!AdjustTokenPrivileges(hToken, FALSE, &tp, 0, NULL, NULL))
    {
        ereport(elevel,
-               (errmsg("could not enable Lock Pages in Memory user right: error code %lu", GetLastError()),
+               (errmsg("could not enable user right \"%s\": error code %lu", _("Lock pages in memory"), GetLastError()),
                 errdetail("Failed system call was %s.", "AdjustTokenPrivileges")));
        CloseHandle(hToken);
        return FALSE;
@@ -172,11 +175,12 @@ EnableLockPagesPrivilege(int elevel)
        if (GetLastError() == ERROR_NOT_ALL_ASSIGNED)
            ereport(elevel,
                    (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
-                    errmsg("could not enable Lock Pages in Memory user right"),
-                    errhint("Assign Lock Pages in Memory user right to the Windows user account which runs PostgreSQL.")));
+                    errmsg("could not enable user right \"%s\"", _("Lock pages in memory")),
+                    errhint("Assign user right \"%s\" to the Windows user account which runs PostgreSQL.",
+                            _("Lock pages in memory"))));
        else
            ereport(elevel,
-                   (errmsg("could not enable Lock Pages in Memory user right: error code %lu", GetLastError()),
+                   (errmsg("could not enable user right \"%s\": error code %lu", _("Lock pages in memory"), GetLastError()),
                     errdetail("Failed system call was %s.", "AdjustTokenPrivileges")));
        CloseHandle(hToken);
        return FALSE;