GetUserPreferredUILanguages() never returns more than two languages
I'm trying to retrieve the complete list of the user's preferred languages from a C++/Qt application, as configured in the "Region & language" page in the user's preferences:
For that, I am trying with the WinAPI function GetUserPreferredUILanguages(), on an up-to-date Windows 10 Pro system.
However, the function always only returns the first entry (the main Windows display language), and "en-US". If English is configured as the main language, then only "en-US" is returned. E.g., if I have (German, French, English) configured, ["de-de", "en-US"] is returned, French is omitted. If I add more languages to the list, they are omitted as well. I also looked at User Interface Language Management, but to no avail. GetSystemPreferredUILanguages() for example only returns "en-US". GetUILanguageFallbackList() returns ["de-de", "de", "en-US", "en"].
The code I use:
// calling GetUserPreferredUILanguages() twice, once to get number of
// languages and required buffer size, then to get the actual data
ULONG numberOfLanguages = 0;
DWORD bufferLength = 0;
const auto result1 = GetUserPreferredUILanguages(MUI_LANGUAGE_NAME,
&numberOfLanguages,
nullptr,
&bufferLength);
// result1 is true, numberOfLanguages=2
QVector<wchar_t> languagesBuffer(static_cast<int>(bufferLength));
const auto result2 = GetUserPreferredUILanguages(MUI_LANGUAGE_NAME,
&numberOfLanguages,
languagesBuffer.data(),
&bufferLength);
// result2 is true, languageBuffer contains "de-de", "en-US"
Is this not the right function to use, or am I misunderstanding something about the language configuration in Windows 10? How can I get the complete list of preferred languages? I see UWP API that might do the job, but if possible, I'd like to use C API, as it integrated more easily with the C++ codebase at hand. (unmanaged C++, that is)
See also questions close to this topic
-
how to display contents of text file one line at a time via timer using python on windows?
this is the code.
def wndProc(hWnd, message, wParam, lParam): if message == win32con.WM_PAINT: hdc, paintStruct = win32gui.BeginPaint(hWnd) dpiScale = win32ui.GetDeviceCaps(hdc, win32con.LOGPIXELSX) / 60.0 fontSize = 36 # http://msdn.microsoft.com/en-us/library/windows/desktop/dd145037(v=vs.85).aspx lf = win32gui.LOGFONT() lf.lfFaceName = "Times New Roman" lf.lfHeight = int(round(dpiScale * fontSize)) #lf.lfWeight = 150 # Use nonantialiased to remove the white edges around the text. # lf.lfQuality = win32con.NONANTIALIASED_QUALITY hf = win32gui.CreateFontIndirect(lf) win32gui.SelectObject(hdc, hf) rect = win32gui.GetClientRect(hWnd) # http://msdn.microsoft.com/en-us/library/windows/desktop/dd162498(v=vs.85).aspx win32gui.DrawText( hdc, **'Glory be to the Father, and to the son and to the Holy Spirit.',** -1, rect, win32con.DT_CENTER | win32con.DT_NOCLIP | win32con.DT_VCENTER ) win32gui.EndPaint(hWnd, paintStruct) return 0
.where it says the "glory be to the father.." prayer I would like that string to actually display a few different prayers on a timer. what I mean is I want to save short prayers to a text file and have the line where it says "glory be.." to change to a new prayer every 60 seconds cycling through a few prayers such as the serenity prayer etc.
-
ubuntu 18.04 docker container
i'm runnung docker on windows 10 desktop. i like to run ubuntu 18.04 docker container. i have pulled ubuntu and ran following docker command Docker up -d ubuntu i'm not seeing image running when i check
docker ps
instead i see image stopped when i check
docker ps -a
why it is like this.? like other images i should see ubuntu running when i check
docker ps
just like wordpress or mysql images.
also i like to mount volume to ubuntu container by using -v tag. let me know if following command is correct or not
docker up -d --name ubuntu -p 80:80 -p 22:22 -v /ubuntu:/home ubuntu
-
X509Certificate2 Constructor fails with Byte[] using Powershell
I am hoping I missed something obvious as I have tried 3 different approaches to generate a PFX/PKCS12 byte array so that the X509Certificate2 class will initiate.
Problem: Code is throwing an exception:
Internal.Cryptography.CryptoThrowHelper.WindowsCryptographicException: 'The specified network password is not correct'
Goal: Generate a X509Certificate2 that includes the private key that passes the following code with the organization's best practice for self-signed certificates in development:
public static X509Certificate2 GetSigningCertificate(byte[] rawBytes) { X509Certificate2 certificate; try { certificate= new X509Certificate2(rawBytes); } catch (Exception ex) { throw new Exception(Errors.MalformedCertificate); } if (!certificate.HasPrivateKey) { throw new Exception(Errors.PrivateKeyIsMissing); } return certificate; }
Code Limitations: Due to a political/organization policy the code, above, that accepts the byte[] cannot be modified by me directly as it is controlled by another team (owners). If after all possible options are exhausted I will then put a formal request document to discuss code changes with good cause.
Platform: Windows 10 Enterprise (1803)
Compile Targets: netstandard2 & .Net 4.7.1
Automation Tooling Approach 1: Using OpenSSL
openssl.exe rand -out C:\Vault\OpenSSL\Certificates\API\customer-support-administration\customer-support-administration.rnd -base64 4096 openssl.exe genrsa -rand "C:\Vault\OpenSSL\Certificates\API\customer-support-administration\customer-support-administration.rnd" -passout pass:"RfTjWnZr4u7x!A%E" -out "C:\Vault\OpenSSL\Certificates\API\customer-support-administration\customer-support-administration-private-key.pem" 2048 openssl.exe genrsa -rand "C:\Vault\OpenSSL\Certificates\API\customer-support-administration\customer-support-administration.rnd" -passout pass:"RfTjWnZr4u7x!A%E" -out "C:\Vault\OpenSSL\Certificates\API\customer-support-administration\customer-support-administration-private-key-encrypted.pem" -des3 2048 openssl.exe rsa -in "C:\Vault\OpenSSL\Certificates\API\customer-support-administration\customer-support-administration-private-key.pem" -pubout -out "C:\Vault\OpenSSL\Certificates\API\customer-support-administration\customer-support-administration-privatekey-corresponding-public-key.pem" openssl.exe rsa -in "C:\Vault\OpenSSL\Certificates\API\customer-support-administration\customer-support-administration-private-key.pem" -RSAPublicKey_out -out "C:\Vault\OpenSSL\Certificates\API\customer-support-administration\customer-support-administration-privatekey-corresponding-rsa-public-key.pem" openssl.exe req -x509 -days 90 -passin pass:"RfTjWnZr4u7x!A%E" -key "C:\Vault\OpenSSL\Certificates\API\customer-support-administration\customer-support-administration-private-key-encrypted.pem" -out "C:\Vault\OpenSSL\Certificates\API\customer-support-administration\customer-support-administration-certificate.cer" -subj "/C=US/ST=CA/L=Newport Beach/O=AutoNow Inc/OU=Application Development/CN=*.autonow.com" openssl.exe req -new -key "C:\Vault\OpenSSL\Certificates\API\customer-support-administration\customer-support-administration-private-key.pem" -out "C:\Vault\OpenSSL\Certificates\API\customer-support-administration\customer-support-administration-certificate-signature.csr" -subj "/C=US/ST=CA/L=Newport Beach/O=AutoNow Inc/OU=Application Development/CN=*.autonow.com" openssl.exe pkcs12 -export -aes256 -CSP "Microsoft Enhanced RSA and AES Cryptographic Provider" -name "" -out "C:\Vault\OpenSSL\Certificates\API\customer-support-administration\customer-support-administration.pfx" -passin pass:"RfTjWnZr4u7x!A%E" -inkey "C:\Vault\OpenSSL\Certificates\API\customer-support-administration\customer-support-administration-private-key-encrypted.pem" -in "C:\Vault\OpenSSL\Certificates\API\customer-support-administration\customer-support-administration-certificate.cer" -passout pass:"VkXp2s5v8x/A?D(G" openssl.exe pkcs12 -out "C:\Vault\OpenSSL\Certificates\API\customer-support-administration\customer-support-administration.pem" -passin pass:"VkXp2s5v8x/A?D(G" -in "C:\Vault\OpenSSL\Certificates\API\customer-support-administration\customer-support-administration.pfx" -passout pass:"VkXp2s5v8x/A?D(G" -clcerts -aes256 -CSP "Microsoft Enhanced RSA and AES Cryptographic Provider"
Automation Tooling Approach 2: Using Powershell cmdlets cls $VerbosePreference = "Continue"
$certStorePath = "Cert:\CurrentUser\My" $friendlyName = "Customer Support Administration Tool SelfSigned Certificate" $name = "*.autonow.com" $dnsname = "services-dev.autonow.com, *.autonow.com, localhost" $notBefore = $(Get-Date).Date.AddDays(-90) $notAfter = $(Get-Date).Date.AddDays(90) $pfxPassword = ConvertTo-SecureString -String "^adhd.Customer.Support.Administration.Tool.20190214" -Force -AsPlainText $selfSignedCertificate = New-SelfSignedCertificate ` -Subject $name ` -DnsName $dnsname ` -KeyAlgorithm RSA ` -KeyLength 2048 ` -NotBefore $notBefore ` -NotAfter $notAfter ` -CertStoreLocation $certStorePath ` -FriendlyName $friendlyName ` -HashAlgorithm SHA256 ` -KeyUsage DigitalSignature, KeyEncipherment, DataEncipherment ` -KeyExportPolicy Exportable ` -TextExtension @("2.5.29.37={text}1.3.6.1.5.5.7.3.1") ` $selfSignedCertificatePath = Join-Path -Path $certStorePath -ChildPath "$($selfSignedCertificate.Thumbprint)".ToUpper() Write-Debug $selfSignedCertificatePath # Create temporary certificate path $tmpPath = "C:\Vault\OpenSSL\Certificates\API\customer-support-administration" If(!(test-path $tmpPath)) { $created = New-Item -ItemType Directory -Force -Path $tmpPath } Write-Debug $tmpPath # Set certificate password here $pfxFilePath = Join-Path -Path $tmpPath -ChildPath "customer-support-administration.pfx" Write-Debug $pfxFilePath $cerFilePath = Join-Path -Path $tmpPath -ChildPath "customer-support-administration.cer" Write-Debug $cerFilePath # Create pfx certificate $exportedPfx = Export-PfxCertificate -Cert $selfSignedCertificatePath -FilePath $pfxFilePath -Password $pfxPassword -Force -CryptoAlgorithmOption AES256_SHA256 $exportedCer = Export-Certificate -Cert $selfSignedCertificatePath -FilePath $cerFilePath -Type CERT -Force # # Get Raw Bytes idea 1 # [Byte[]]$pfxBytes = [System.IO.File]::ReadAllBytes($exportedPfx.FullName) $pfx = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2 -ArgumentList (,$pfxBytes), $pfxPassword If (-not $pfx.HasPrivateKey) { throw [System.Exception]::new("The certificate is incompatible with the security requirements.") } # Read directly from the file for the raw bytes $pfxBase64 = [Convert]::ToBase64String($pfxBytes) # moment of truth instantiate the certificate using the security package code for idea 1 [Byte[]]$pfxBytes = [Convert]::FromBase64String($exportBase64) $pfx = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2 -ArgumentList (,$pfxBytes),$pfxPassword If (-not $pfx.HasPrivateKey) { throw [System.Exception]::new("The rehydrated certificate is incompatible with the security requirements.") } # # Get Raw Bytes idea 2 # $pfxKeyFlags = [System.Security.Cryptography.X509Certificates.X509KeyStorageFlags]::Exportable -bor [System.Security.Cryptography.X509Certificates.X509KeyStorageFlags]::PersistKeySet -bor [System.Security.Cryptography.X509Certificates.X509KeyStorageFlags]::UserKeySet $pfx = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2 $pfx.Import($pfxBytes, $pfxPassword, $pfxKeyFlags) If (-not $pfx.HasPrivateKey) { throw [System.Exception]::new("The certificate is incompatible with the security requirements.") } $exportedBytes = $pfx.Export([System.Security.Cryptography.X509Certificates.X509ContentType]::Pfx, $pfxPassword) $exportBase64 = [Convert]::ToBase64String($exportedBytes) # test the instantiate [Byte[]]$newPfxBytes = [Convert]::FromBase64String($exportBase64) $pfx = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2 -ArgumentList ($newPfxBytes,$pfxPassword) If (-not $pfx.HasPrivateKey) { throw [System.Exception]::new("The rehydrated certificate is incompatible with the security requirements.") } # moment of truth instantiate the certificate using the security package code [Byte[]]$newPfxBytes = [Convert]::FromBase64String($exportBase64) $pfx = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2 -ArgumentList (,$newPfxBytes) If (-not $pfx.HasPrivateKey) { throw [System.Exception]::new("The rehydrated certificate is incompatible with the security requirements.") }
The end result is still an exception is thrown.
New-Object : Exception calling ".ctor" with "1" argument(s): "The specified network password is not correct. " At line:2 char:8 + $pfx = New-Object System.Security.Cryptography.X509Certificates.X509C ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: (:) [New-Object], MethodInvocationException + FullyQualifiedErrorId : ConstructorInvokedThrowException,Microsoft.PowerShell.Commands.NewObjectCommand
The output of idea #2 base64:
PS C:\WINDOWS\system32> $exportBase64 MIIKwAIBAzCCCnwGCSqGSIb3DQEHAaCCCm0EggppMIIKZTCCBfYGCSqGSIb3DQEHAaCCBecEggXjMIIF3zCCBdsGCyqGSIb3DQEMCgECoIIE9jCCBPIwHAYKKoZIhvcNAQwBAzAOBAgi31AW/5cI5gICB9A EggTQVgPWXArFCY2eg2jv+hDLZsc+i3wEqw4Cy2CYgcj86WnRE0n/zVcNzi9lyH5jK1zpBfTpAnfTO4WNG8cdQ5qCtOy9TjkTyrGYrXywrGHgLYmHpsg43uMMWcihWO5+zek4YP3MQDtyuQT2+hCaviFwFu TovlaLHjGlNcYAz7AlL/6sJ54EzTjo8zfKW08zaR1GsEeP9odYIlgVEltJEgsW69Ed7v1uNs5+vprEecVvegTr5o3LzV9UflF8ye4wv65ZtjJdb+9uTHeYLwje0woWvWfGAQ1KBZTWyJeIWEGhs04vqhKbO Dak+KmvjYh2U3BYYLKlvCDtYulFA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-out privatekey.pem 1024 openssl req -new -x509 -key privatekey.pem -out publickey.cer -days 10000 openssl pkcs12 -export -out public_privatekey.pfx -inkey privatekey.pem -in publickey.cer
The command above does produce a pfx that will pass the constructor
# use openssl generic pfx $pfx = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2 -ArgumentList "C:\Vault\OpenSSL\Certificates\API\public_privatekey.pfx" If (-not $pfx.HasPrivateKey) { throw [System.Exception]::new("The openssl generic certificate is incompatible with the security requirements.") }
If I reference the PFX file it does pass the constructor and works!? If I pass the raw file bytes again it works?! Where in the processes of what I wrote for automation fails while the overly generic/simple one works?
# use openssl generic pfx [Byte[]]$pfxBytes = [System.IO.File]::ReadAllBytes("C:\Vault\OpenSSL\Certificates\API\public_privatekey.pfx") $pfx = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2 -ArgumentList (,$pfxBytes) If (-not $pfx.HasPrivateKey) { throw [System.Exception]::new("The openssl generic certificate is incompatible with the security requirements.") }
-- Update --
Using the OpenSSL way to use non-encrypted on genrsa and the pkcs12 commands to have a -passin pass: and -passout pass: so they'll be treated as blank. This seems to work however my colleagues and myself are curious if not having an encrypted private key and export password on the pfx is best practice. If not how do we get it up to par?
openssl.exe rand -out C:\Vault\OpenSSL\Certificates\API\customer-support-administration\customer-support-administration.rnd -base64 4096 openssl.exe genrsa -rand "C:\Vault\OpenSSL\Certificates\API\customer-support-administration\customer-support-administration.rnd" -out "C:\Vault\OpenSSL\Certificates\API\customer-support-administration\customer-support-administration-private-key.pem" 2048 openssl.exe genrsa -rand "C:\Vault\OpenSSL\Certificates\API\customer-support-administration\customer-support-administration.rnd" -out "C:\Vault\OpenSSL\Certificates\API\customer-support-administration\customer-support-administration-private-key-encrypted.pem" 2048 openssl.exe rsa -in "C:\Vault\OpenSSL\Certificates\API\customer-support-administration\customer-support-administration-private-key.pem" -pubout -out "C:\Vault\OpenSSL\Certificates\API\customer-support-administration\customer-support-administration-privatekey-corresponding-public-key.pem" openssl.exe rsa -in "C:\Vault\OpenSSL\Certificates\API\customer-support-administration\customer-support-administration-private-key.pem" -RSAPublicKey_out -out "C:\Vault\OpenSSL\Certificates\API\customer-support-administration\customer-support-administration-privatekey-corresponding-rsa-public-key.pem" openssl.exe req -x509 -days 90 -key "C:\Vault\OpenSSL\Certificates\API\customer-support-administration\customer-support-administration-private-key.pem" -out "C:\Vault\OpenSSL\Certificates\API\customer-support-administration\customer-support-administration-certificate.cer" -subj "/C=US/ST=CA/L=Newport Beach/O=AutoNow Inc/OU=Application Development/CN=*.autonow.com" openssl.exe req -new -key "C:\Vault\OpenSSL\Certificates\API\customer-support-administration\customer-support-administration-private-key.pem" -out "C:\Vault\OpenSSL\Certificates\API\customer-support-administration\customer-support-administration-certificate-signature.csr" -subj "/C=US/ST=CA/L=Newport Beach/O=AutoNow Inc/OU=Application Development/CN=*.autonow.com" openssl.exe pkcs12 -export -aes256 -CSP "Microsoft Enhanced RSA and AES Cryptographic Provider" -name "" -out "C:\Vault\OpenSSL\Certificates\API\customer-support-administration\customer-support-administration.pfx" -inkey "C:\Vault\OpenSSL\Certificates\API\customer-support-administration\customer-support-administration-private-key.pem" -in "C:\Vault\OpenSSL\Certificates\API\customer-support-administration\customer-support-administration-certificate.cer" -passout pass: openssl.exe pkcs12 -out "C:\Vault\OpenSSL\Certificates\API\customer-support-administration\customer-support-administration.pem" -in "C:\Vault\OpenSSL\Certificates\API\customer-support-administration\customer-support-administration.pfx" -clcerts -aes256 -CSP "Microsoft Enhanced RSA and AES Cryptographic Provider" -passout pass: -passin pass: # This now works [Byte[]]$pfxBytes = [System.IO.File]::ReadAllBytes("C:\Vault\OpenSSL\Certificates\API\customer-support-administration\customer-support-administration.pfx") $pfx = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2 -ArgumentList (,$pfxBytes) If (-not $pfx.HasPrivateKey) { throw [System.Exception]::new("The certificate is incompatible with the security requirements.") } $base64Pfx = [System.Convert]::ToBase64String($pfxBytes) # moment of truth instantiate the certificate using the security package code for updated openssl commands [Byte[]]$pfxBytes = [Convert]::FromBase64String($base64Pfx) $pfx = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2 -ArgumentList (,$pfxBytes) If (-not $pfx.HasPrivateKey) { throw [System.Exception]::new("The rehydrated certificate is incompatible with the security requirements.") } $pfx | select * $base64Pfx = [System.Convert]::ToBase64String($pfxBytes) # moment of truth instantiate the certificate using the security package code for idea 1 [Byte[]]$pfxBytes = [Convert]::FromBase64String($base64Pfx) $pfx = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2 -ArgumentList (,$pfxBytes) If (-not $pfx.HasPrivateKey) { throw [System.Exception]::new("The rehydrated certificate is incompatible with the security requirements.") }
-
Is it possible that a .jar file called from c++ writes a file?
I am trying to get the output of a .jar file from my C++ used in UWP. The jar contains a complex algorithm and writes the output to a file. Calling it through the console works perfect but inside my program it seems to execute but not creating a file.
Don't ask now why I'm desperating getting the output via a file instead of Pipes. This is also a question from me: CreateProcess Pipe is always empty
It actually returns 1 so it tells me that it doesn't find the file.
This is how I try to implement my .jar in my C++ dll:
STARTUPINFO sInfo; ZeroMemory(&sInfo, sizeof(sInfo)); PROCESS_INFORMATION pInfo; ZeroMemory(&pInfo, sizeof(pInfo)); sInfo.cb = sizeof(sInfo); //if (!SetHandleInformation(wPipe, HANDLE_FLAG_INHERIT, 0)) //return "Error SetHandleInformation"; if (!CreateProcess(TEXT("C:\\\\Program Files (x86)\\Java\\jdk1.8.0_161\\jre\\bin\\java.exe"), TEXT("-jar decode_fileout.jar"), NULL, NULL, false, CREATE_DEFAULT_ERROR_MODE, NULL, NULL, &sInfo, &pInfo)) { return 0; } WaitForSingleObject(pInfo.hProcess, INFINITE); string fileContent; ifstream myfile("decode.txt"); if (myfile.is_open()) { getline(myfile, fileContent); myfile.close(); } else return 1; char *endPtr; if (isdigit(fileContent[0])) return strtoll(fileContent.c_str(), &endPtr, 10); else return 2;
-
C++ Select Folder, Include Files
I'm currently working on a qt application for Windows. The user needs to be able to select a directory to load all files from. I am having an issue related to this. It seems pretty stupid, but I keep getting the same feedback. The end users get confused by the file dialog because they navigate to the folder, but it doesn't show any files. Even though they are selecting a folder, it confuses them to not see files in the directory.
So I decided to dig into it and do some research. From what I have uncovered, it seems like there are basically 2 options. The
IFileOpenDialog
withFOS_PICKFOLDERS
, which is what I am currently using via qt'sQFileDialog
. OrSHBrowseForFolder
, which does work, but is pretty limited.Am I missing any options? It seems like
IFileOpenDialog
that showed the files without allowing the user to select them would be ideal. Is there any way to accomplish this? I found a lot of older information saying it was not possible, but nothing definitive the is more recent. -
Font is not being installed using WinAPI
I'm trying to install TTF font permanently in windows using winapi, but when I place it in C:/Windows/Fonts it doesn't work.
I tried to change way of writing font into a folder, but didn't succeed.
if (!PathFileExistsA("C:/windows/fonts/Raleway-Regular.ttf")) { auto hdl = CreateFileA("C:/windows/fonts/Raleway-Regular.ttf", GENERIC_WRITE, NULL, NULL, CREATE_ALWAYS, NULL, NULL); DWORD written; WriteFile(hdl, font, 178520, &written, NULL); if (written < 178520) { MessageBoxA(NULL, "Could not install required fonts [error 1]", "Error", MB_OK | MB_APPLMODAL); CloseHandle(hdl); std::terminate(); } CloseHandle(hdl); AddFontResourceA("C:/windows/fonts/Raleway-Regular.ttf"); }
I checked MSDN and I think this is how I install fonts. However, this doesn't work somewhy.
UPD: I added error check to every single function but they're all succeed
-
SailsJS i18n module not changing lang file even the locale was changed
I debugging a SailsJS app, if I print the sails global variables it has the right values for locales, and defaultLocale, etc...
I changing the locale with Accept-Language header in PostMan and works like a charm.
Even it has the right locales, i18n module is taking always the default language translation file. Does someone know what could be happening?
Regards
-
Angular mat-icon is being "translated"?
Summary: I am using the "+" sign material icon on a page to represent adding a new item.
On the English version of the site, it displays fine. On the Spanish version of the site, it displays "ñ"
Question: Should I not have any text in between the tags? Or should I not put a translation element at all?
I tried looking into this but couldn't find anything through SO or google, I also did not see it on the documentation page: https://material.angular.io/components/icon/overview
<mat-icon (click)="doStuff()" i18n="@@AaBBCcDd_Y2_14">add</mat-icon>
Expected: To keep the "+" sign in both English and Spanish versions of sites.
Actual: Translating to "ñ"
-
How to read 2 columns from excel file (xlsx) and write it to resource properties as key=value pair
I am trying to generate messages_[en/da/bg].properties file from the given set for excel (xlsx) files. Each excel sheet is provided with two columns as key-value pair. I have to read each file and write it to generate messages_en.properties file for i18n.
If I have excel sheets with filenames like
locales_ENG.xlsx
,locales_DAN.xlsx
&locales_BGR.xlsx
then it should generate files as:messages_en.properties
messages_da.properties
messages_bg.properties
-
Change of language depending on the logged in user
I need to make translation dependent on data stored in User entity. For example, i have User entity with column Language. If user has EN in it, i need to translate views into english etc. After logging in i need to check what type of language has user and load translated view.
Should i use for that https://symfony.com/doc/current/event_dispatcher.html if i do how should i do it?
I have tried make something with Locale setDefault function in IF statement but it dosen't work
-
One page but multiple top-level domain names: how to tag?
We want translate our .com site, and decided to use different country specific top-level domain names, like:
- www.mywebsite.com
- www.monsiteweb.fr
- www.misitioweb.es
- ...
Now, from a maintenance perspective, we prefer to use the same host AND page for all languages. So, for example, every top level domain will link to the exact same index.php file, and we'll just check the top level domain in PHP and fetch the correct language from the database.
If we want to change the layout a bit, we only need to change one file (index.php), and not a file per language, that's a bit the idea. The same goes for all our other .php pages on our host.
My question is: how should I do the HTML-tagging properly with this set up? Should I just include all the tags in the same .php file, like so?
<head> <title>Widgets, Inc</title> <link rel="alternate" hreflang="en" href="http://www.mywebsite.com" /> <link rel="alternate" hreflang="fr" href="www.monsiteweb.fr" /> <link rel="alternate" hreflang="es" href="www.misitioweb.es" /> <link rel="alternate" hreflang="x-default" href="http://www.mywebsite.com" /> </head>
And for other pages:
<head> <title>Widgets, Inc</title> <link rel="alternate" hreflang="en" href="http://www.mywebsite.com/about.php" /> <link rel="alternate" hreflang="fr" href="www.monsiteweb.fr/about.php" /> <link rel="alternate" hreflang="es" href="www.misitioweb.es/about.php" /> <link rel="alternate" hreflang="x-default" href="http://www.mywebsite.com/about.php" /> </head>
Because this page says: "If two pages don't both point to each other, the tags will be ignored. This is so that someone on another site can't arbitrarily create a tag naming itself as an alternative version of one of your pages."
And in our case, it's not that "two pages" are pointing to each other, because it's only one page.
Another possibility would be that I echo the tags depending on the language selected but then again, it's still the same .php page.
So... What's to proper way to do here?
-
How to translate a webpage with JavaScript and cookie
I want to add a cookie to my JavaScript translation function, so that the language is stored in a session each time the user changes it.
My JSFiddle: https://jsfiddle.net/e7skfjqj/
Has anyone an approach for this?
I tried to combine with this cookie solution, but it failed due to the JS generation of the selection menu.
-
ErrorDocument 404 for a multilingual html site
I have a German HTML website with a custom 404 rule in the htaccess file. Now I have added a second language (en) and I want to add an English custom 404 page.
I have read multiple post about custom 404 for multilingual websites but they are all for php sites and I need one for an html site.
for PHP I found the following code:
ErrorDocument 404 /404.php RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^([a-z]{2})/ $1/404.php [L]
/en/404.php as this:
<?php // return correct 404 status code http_response_code(404); // rest of the 404 handler content ?>
I am relatively new to htaccess files and I am hoping that somebody can show me the code that I need for html site with multiple languages.
Thanks in advance!
-
What could cause only one of my sites to malfunction after update to multilingual plug-in MPML?
I manage 5 websites using WordPress as the CMS. All use a multilingual plug-in called WPML. At some point during an update, one of the sites decided not to function correctly. I am unable to upload images or generate blog post for other languages. The strange thing is, 3 of the sites use the same theme and plugins and they work perfectly fine. All sites are also on the same server.
Usually when I have some weird issue after an update I can find the fix within the plug-ins, host, or theme itself. Nothing has worked thus far. I even went to using older updates and restored the site to last week, the issue still persist, nothing changes.
-
How to configure the robots.txt file with a multilingual site?
I have a site with Drupal 8 and I activate English and French (Language from the URL path prefix). Here is what my url resembles :
https://www.domaine.com/en/node/add
https://www.domaine.com/fr/node/add
And here is the current configuration of my robots.txt file :
# Paths (clean URLs) Disallow: /admin/ Disallow: /comment/reply/ Disallow: /filter/tips Disallow: /node/add/ Disallow: /search/ Disallow: /user/register/ Disallow: /user/password/ Disallow: /user/login/ Disallow: /user/logout/
How to configure the robots.txt file with a multilingual site ?
Do I have to add fr and praise each url or will it do it alone ?