How do I enable translation to other languages in Openstack Horizon? - openstack-horizon

I am tasked to enable different languages in Openstack Horizon.
I am working on a horizon page built on top of dev stack. The Horizon page is pulled from here: https://github.com/openstack/horizon.
I want to enable translation to different languages in Horizon.
I tried to follow this documentation: https://docs.openstack.org/horizon/latest/contributor/topics/translation.html
This is an example of my code, I am trying to translate this phrase: “API Access” found in the panel on the main page :
Before editing the code, I saw that there is a corresponding translated message in openstack_dashboard/locale/zh_CN/LC_MESSAGES/django.po:
msgid "API Access"
msgstr "访问API"
This is what I did:
Firstly, In openstack_dashboard/dashboards/project/api_access/panel.py, I edited name = _("API Access") to name=pgettext("API Access", "API Access"):
from django.utils.translation import pgettext
import horizon
class ApiAccess(horizon.Panel):
name = pgettext("API Access","API Access")
slug = 'api_access'
Secondly, I ran tox -e manage -- extract_messages in the main openstack/horizon folder
Thirdly, I ran tox -e manage -- update_catalog in the main openstack/horizon folder
After I run it, this following keyword "API Access" is still not translated.
(i.e. I started horizon, went to settings, and change the language to zh-cn. But the word "API Access" is still in English.)
Not sure if this is helpful:
In openstack_dashboard/locale/Django.pot, I see this:
#: openstack_dashboard.dashboards/project/api_access/panel.py:22
msgctxt "API Access"
msgid "API Access"
msgstr ""
Grateful to anyone who can help me solve this translation issue.

Nevermind, I manage to fix it by switching to clean branch and just follow the documentation!

Related

how to run Groovy script in Netbeans?

I'm trying out NetBeans for editing Groovy code. (I'm new to Groovy, and it's been a long time since I did any Java development).
At some point I installed the Groovy plugin via the "plugins" tool. But it does not have the green checkmark under "active", and choosing the Groovy plugin does not make the Activate/Deactivate/Uninstall buttons available. Oh well...
So let's create a project...
Choose "new project". I'm choosing "Java with Maven" just because it's the first one.
Hit "Finish"...and voila, I have a project.
Let's create a file...
Right click the project package in the left pane, choose "new"
Choose "Groovy Script" for a type, hit "finish"
Hey, I have a very simple script. Looks like it should say "Hello chris!" when done.
Hit the "play" button on the toolbar....things appear in the output window.
But wait a minute...the output is "Hello World!", and it should be "Hello chris!" It looks like "HelloWorld" is coming out of "Mavenproject1.java".
How can I (or can I) just run my script from within NetBeans?
UPDATE: per #andrewJames suggestion, I tried working that tutorial. (It looks like the tutorial may be a bit out of date.)
I created a "Java Ant" project, as that was the only one that offered me the option of not creating a "Main Class File".
I created the Java form, and the Groovy class, as directed.
When I run the project, I get an error message saying "Error running forked groovyc".
I get that same error whether I'm running on a machine with a groovyc executable or not, so I suspect that there's something about the configuration that I need to change in order to point to the groovyc executable.
Probably something to do with the build.xml file...but I can't seem to figure out how to edit that to change the search path for the groovyc step.
I had the same problem that NB doesn't run a Groovy script out of the IDE like Eclipse does. I logged an issue and spent more than a year on the netbeans-dev mailing list advocating for it. Often replied to with "we'll be happy to review your pull request" type of stuff. Eventually, when I rage quit the mailing list with a scathing message, Geertjan replied to the issue with a solution.
So, in short, use the old plugin to create a Groovy project and change line 26 in groovy-build.xml to
<groovyc srcdir="#{srcdir}" sourcepath="#{sourcepath}" destdir="#{destdir}" encoding="${source.encoding}" excludes="#{excludes}" includeAntRuntime="true" fork="false">
You can then run your script with Shift+F6.
The project needs the Groovy jars added. It works for me on NB 11, 12 & 13 with Groovy 2.x and Java 8, 11 & 14 so far. I haven't tried it with Groovy 3.x as the groovy-all.jar is deprecated so you'll have to maven or manually manage the Groovy jars.
Also, I collaborated a bit with someone on a new plugin. It works as is but new development has stalled.

Faulty Url in FsLab package for F#

I just downloaded this report called Analyzing and Visualizing Data with F# and am having a hard time just running the first example. This should probably be expected since the report is 7 years. I am running the first script which is as follows.
#load "packages/FsLab/FsLab.fsx"
open FSharp.Data
open XPlot.GoogleCharts
let wb = WorldBankData.GetDataContext()
wb.Countries
I get an error message that reads
Response from http://api.worldbank.org/country?per_page=1000&format=json&page=1:
{ "statusCode": 404, "message": "Resource not found" }
It looks like the url is broken because it seems that the worldbank has updated its api. When I use the url http://api.worldbank.org/v2/country in my browser it works. I noticed when I went to the source code that they have the base url hard coded in, so I was thinking I would just need to add "v2/" to it and it would work, but I am unfamiliar with how to load a edited library into my script.
Yes, your investigation is correct, even banks sometimes change their APIs :)
As for adding the library to your script, it depends on how your environment looks like, but basically you can fix the problem locally and/or globally.
For the local solution, once you compile your downloaded library with modified url, you can load or reference it as described here.
For the global solution, send a pull request that fixes the link in this file, Tomáš Petřiček (the repo owner) is generally active and should merge it. And you will improve the world a little bit.

While working on Robot framework , encountered an Import error message when attempting to add Resource in Setting Section?

In Robot Framework , I have segregated the details into Page objects, keywords and scripts.
After adding keywords in PO, I wanted to add details in Keywords. Here, in Settings section while I give the following details:
*** Settings ***
Library SeleniumLibrary
Resource Resources/PO/Sign-in.robot
I even tried using absolute path by referencing ../ at the beginning. Still, system is unable to recognize it and throwing an error message "Import File Not Found".
What Should I be doing? Please, let me know?
First, you show in the screenshot, the use of a variable ${Resources}, it would be normal for the IDE to not recognize that value for a path. Even so, running the test case may work as expected.
Second, if you want to use the relative path, then the correct value should be:
Resource ../PO/Sign-in.robot

How to make proper module translations in Drupal 8?

I have to prepare modules translations, but the documentation is not helping me.
I know i can use *.pot files, but i can't fully understand how dupal is managing translations.
If i add translations/example.pot drupal will take care of everything else?
First modify module_name.info.yml add:
'interface translation project': block_example
'interface translation server pattern': modules/examples/%project/translations/%language.po*
Then create in your module directory folder translations.
Add translations/language.po files, where you will store translations.
language.po:
msgid "your id to translate"
msgstr "translations test"
template.html.twig:
<p>{% trans %}your id to translate{% endtrans %}</p>
Then go to your Drupal admin page Configuration/User interface translation, there you can filtr your msgid and see already translated files.
You may have to use IMPORT {just upload .po file}
Translations are imported automatically when you install your module.

Reproducing the blocked exe "unblock" option in file properties in windows 2003

When I download my program from my website to my windows 2003 machine, it has a block on it and you have to right click on the exe, then properties, then select the button "Unblock".
I would like to add detection in my installer for when the file is blocked and hence doesn't have enough permissions.
But I can't eaisly reproduce getting my exe in this state where it needs to be unblocked.
How can I get the unblock to appear on my exe so I can test this functionality?
This is done using NTFS File Streams. There is a stream named "Zone.Identifier" added to downloaded files. When IE7 downloads certain types of file that stream contains:
[ZoneTransfer]
ZoneId=3
The simplest way to set it is to create a text file with those contents in it, and use more to add it to the alternate stream.
Zone.Identifier.txt:
[ZoneTransfer]
ZoneId=3
Command:
more Zone.Identifier.txt > file.exe:Zone.Identifier
Then, the way for you to check it would be to try to open the Zone.Identifier stream and look for ZoneId=3, or simply assume that if the stream exists at all that your user will receive that warning.
It's also important to note that this has nothing to do with permissions. Administrators see the same warning; it's to do entirely with the source and type of file. The entire stream goes away when users uncheck the "Always ask before opening this file" box and then click Run.
There is a supported API for this, documented on MSDN. Search on MSDN for "Persistent Zone Identifier Object". Basically you CoCreateInstance with CLSID_PersistentZoneIdentifier and request an IPersistFile interface. You then call IPersistFile::Load with the name of the file in question. Next, QI for an IZoneIdentifier interface and use IZoneIdentifier::GetId to obtain the zone of the file. If there was no "mark of the web", you should get URLZONE_LOCAL_MACHINE. The ZoneId of 3 mentioned in the other reply is URLZONE_INTERNET. (The enumeration is called URLZONE and is also documented on MSDN, or see sdk\inc\urlmon.h.) You can remove or change the "mark of the web" by calling IZoneIdentifier::Remove or IZoneIdentifier::SetId and then call IPersistFile::Save. There are more details about all of this on MSDN. Good luck!
Thanks for this it helped me a lot.
You can make the process even easier if you create a batch file with the contents.
echo [ZoneTransfer] > Zone.Identifier
echo ZoneId=3 >> Zone.Identifier
more Zone.Identifier > %1:Zone.Identifier
This will generate the Zone.Identifier for you and mark the file accordingly.
To run it just supply the file name e.g. if the file is called mark.bat
mark.bat myfile.txt

Resources