Item name assignment in lang file not behaving as documentation suggests - translation

I am trying my hand at creating an Add-On for Minecraft Bedrock edition on a Windows 10 PC, v 1.18.12 . I've successfully created an item that I can get to appear in the game (yay, me!), but the item name is working oddly. According to the documentation at https://wiki.bedrock.dev/guide/custom-item.html the name should be set in the resource pack's en_us.lang file using
item.NAMESPACE:THING.name=THINGNAME
but when I do that the item shows up in my Minecraft test world as item.NAMESPACE:THING, and the only way I can get the name to actually appear in Minecraft is to drop .name, i.e. set
item.NAMESPACE:THING=THINGNAME
after which the item is labeled as THINGNAME within the test world. Is this expected behavior? The Vanilla Resource Pack at https://github.com/ZtechNetwork/MCBVanillaResourcePack has its .lang files set up with the .name suffix, consistent with the bedrock.dev instructions I linked to above, so I don't get what's going on here, and based on my programming experience I'm concerned that excluding the .name suffix may have negative side effects. Any insight into what's going on would be appreciated.

Related

Couldn't select folder A/INBOX: NO / [CANNOT] Non-supported characters in mailbox name

I am accessing an IMAP server using Python imaplib.
I am doing this for three different mailboxes box1#mydomain.de, box2#mydomain.de, other#otherdomain.de.
In each case, I want to access the folder INBOX.
In each case, a folder listing confirms that this folder exists at the top level:
b'(\HasNoChildren) "." "INBOX"'
All three mailboxes are at the same ISP and are accessed via the same IMAP server name.
The code is working fine for box2 and other.
For box1, however, it fails with this error message:
Couldn't select folder A/INBOX: NO / [CANNOT] Non-supported characters in the mailbox name
I have determined that A will always be the name of the first subfolder:
b'(\HasChildren) "." "A"'
If I rename A to Z, the next existing subfolder will take the place of A in the error message.
Question 1: Why is the server prepending a subfolder when I ask for INBOX?
I gather that the error message tells me that the / in the name is a problem,
because the server uses . as a folder name separator?
Question 2: Why is the server so silly to construct a name it will not accept?
Question 3: What can I do to repair the mailbox? (I have no control of that server.)
Question 4: Does anybody know a programmer who has ever written code using IMAP and thinks IMAP is a good protocol? (semi-serious question)
Thank you #Max, your request for code did the job. I used the debugger and found the problem in the framework I am using:
I am using a subclass of mailprocessing.processor.imap.ImapProcessor that turns what is meant as a command-line tool into an API for my script.
ImapProcessor, unless told otherwise, by default uses this logic in its constructor:
# This should catch at least some of these weird IMAP servers
# that store everything under INBOX. Use --folder-prefix for
# the rest for now.
if cmd_prefix is None and root_has_children:
self.prefix = root_folder
and this root_folder is simply the first folder in the folder list,
in my case A.
If I construct my object as ImapProcessor(..., folder_prefix=""), all works as intended.
(Overall, mailprocessing has nice functionality, but also a number of weird decisions, plus two bugs to get over.)
So the answers to my questions 1, 2, 3 are "it doesn't", "it isn't", "no repair needed". Instead, my code simply called a functionality I had not expected to exist.

How do I retrieve / iterate Win11 IExplorerCommand context menu items?

About five years back, I wrote a program for a customer which effectively re-created the Windows Explorer context menu inside the program -- if they clicked on the object representing their data file, it showed the context menu they'd see in Explorer, including the Dropbox sharing menu items. (The mechanism is similar to the one here: https://github.com/linquize/explorerplus-custom/blob/master/Explorer%2B%2B/Helper/ContextMenuManager.cpp -- finding all the IContextMenu COM objects from the registry and querying each in term to add their menu items.)
This has worked fine all this time... but Windows 11 has changed things, and the new version of the Dropbox client (v159) has broken backwards compatibility.
To sum up, the old-style IContextMenu COM objects could all be queried under HKEY_CLASSES_ROOT*\shellex\ContextMenuHandlers (or similar locations), but the new short-form context menu on Win11 uses IExplorerCommand objects instead. Explorer includes them on the old-style context menu as well as the IContextMenu iterations -- in Dropbox's case this led to a bug which caused the menu items to be duplicated. They seem to have just fixed this in v159 by suppressing the IContextMenu items... meaning they don't show up in my menu any more.
So how can I find and iterate all the IExplorerCommand objects which are added to the new short-form context menu? Including the cloud-provider commands from apps like Dropbox?
For what it's worth, I can find class IDs for the Dropbox items in their AppxManifest.xml:
<Extensions>
<desktop3:Extension Category="windows.cloudFiles">
<desktop3:CloudFiles>
<desktop3:CloudFilesContextMenus>
<desktop3:Verb Id="Dropbox01UpgradeCommand"
Clsid="F3BC3DAF-431B-4F0E-B105-E9BB76335840" />
<desktop3:Verb Id="Dropbox02ShareCommand"
Clsid="7F4C5B83-2680-40AF-9AE9-2161AA759EF2" />
And it also defines the COM server they're running on:
<com:Extension Category="windows.comServer">
<com:ComServer>
<com:SurrogateServer AppId="67233DFC-D70F-4D8E-A068-6877D86826BC"
DisplayName="ms-resource:ShellExtensionServerDisplayName">
<com:Class Id="7F4C5B83-2680-40AF-9AE9-2161AA759EF2"
Path="DropboxExt64.55.0.dll" ThreadingModel="STA" />
<com:Class Id="F3BC3DAF-431B-4F0E-B105-E9BB76335840"
Path="DropboxExt64.55.0.dll" ThreadingModel="STA" />
And these entries are visible under HKEY_CLASSES_ROOT\PackagedCom, e.g:
[HKEY_CLASSES_ROOT\PackagedCom\Package\DropboxInc.Dropbox_159.4.5870.0_x86__wkt425jdc3sga\Server\0]
[HKEY_CLASSES_ROOT\PackagedCom\Package\DropboxInc.Dropbox_159.4.5870.0_x86__wkt425jdc3sga\Class{7F4C5B83-2680-40AF-9AE9-2161AA759EF2}]
[HKEY_CLASSES_ROOT\PackagedCom\Package\DropboxInc.Dropbox_159.4.5870.0_x86__wkt425jdc3sga\Class{F3BC3DAF-431B-4F0E-B105-E9BB76335840}]
...but I can't even co-create an IUnknown for any of these class IDs -- even within a shell extension running within Windows Explorer, let alone my own app. I get an HRESULT error 0x80040154 (-2147221164)
Basically, how do I locate these items? (Note that if I use ICatInformation::EnumClassesOfCategories(), the Dropbox items aren't defined with category information.) If there's no way to construct a complete list, is there at least a way to access known objects like the Dropbox ones?

libreoffice - run (python) macro to insert cross reference from Gnu/Linux command line

I have verified that I can run both normal office and python macros from within office but I still haven't figured out how to run one (even the hello world one) from the command line.
I have googled and looked at other answers here but I'm still not entirely clear how to run an open office macro from the command line:
https://forum.openoffice.org/en/forum/viewtopic.php?f=20&t=8232
suggests to use:
office writer.odt "macro://Standard.Module1.Macro1()"
I have also seen:
office "macro://Standard.Module1.Macro1()" writer.odt
Either way around this just opens the document and and neither runs a macro nor reports an error.
Whereas How to call an existing LibreOffice python macro from a python script
suggests to run office listening on a port and communicate via that.
If I can get that far I still need to find API documentation that will explain how to insert an anchor (as per my other question
asciidoc: is there a way to create an anchor that will be visible in libreoffice writer?)
I'm using RHEL7 for context.
update
oowriter "foo.odt" macro:///Standard.Module1.addXref
works with a office basic macro.
I still haven't figured out the python one.
One issue is I can't find any debug information to look at. Are there any log files anywhere?
Another issue is which version of python to use.
The RHEL package installs site packages for python 2.7.
>rpm -q --whatprovides /usr/bin/writer
libreoffice-writer-4.3.7.2-5.el7_2.1.x86_64
>rpm -ql libreoffice-pyuno-4.3.7.2-5.el7_2.1
...
/usr/lib64/python2.7/site-packages/uno.py
Libreoffice5.1 includes 3.5 with the distro:
>/opt/libreoffice5.1/program/python --version
Python 3.5.0
So to start with I am looking for a hello world python example that pairs a known version of python with a known version of office. Preferably either of the two above (writer 4.3.7 & python 2.7? or writer 5.1 & python 3.5).
update2
Using python3.5 as installed with office5.1 I have a working hello world using the following:
import uno
# get the uno component context from the PyUNO runtime
localContext = uno.getComponentContext()
# create the UnoUrlResolver
resolver = localContext.ServiceManager.createInstanceWithContext(
"com.sun.star.bridge.UnoUrlResolver", localContext )
# connect to the running office
ctx = resolver.resolve( "uno:socket,host=localhost,port=2002;urp;StarOffice.ComponentContext" )
smgr = ctx.ServiceManager
# get the central desktop object
desktop = smgr.createInstanceWithContext( "com.sun.star.frame.Desktop",ctx)
# access the current writer document
model = desktop.getCurrentComponent()
# access the document's text property
text = model.Text
# create a cursor
cursor = text.createTextCursor()
# insert the text into the document
text.insertString( cursor, "Hello World", 0 )
This works with either version of open office via:
/usr/bin/oowriter --accept="socket,host=localhost,port=2002;urp;StarOffice.ServiceManager"
So the final part is to add the cross reference.
It looks like the command needs an extra slash. This worked for me on Ubuntu:
lowriter "Untitled 1.odt" macro:///Standard.Module1.SayHello
That calls this method in the module named Module1 under My Macros & Dialogs / Standard:
Sub SayHello
MsgBox("Hello, World!")
End Sub
The above approach only works for Basic macros. For Python macros, the standard command line approach is to connect to a listening instance of Office. Warning: This will be much (perhaps 10x) slower than running from within Office.
The link you suggested shows how to call a Python macro from a different Python script, which is more complex than what we need here. Instead, put the connecting code (starting with localContext = uno.getComponentContext()) and macro code in the same script. For an example of what should go in the script, see "First play with the Python shell to get familiar" at http://christopher5106.github.io/office/2015/12/06/openoffice-libreoffice-automate-your-office-tasks-with-python-macros.html.
As far as creating anchors, there are a number of different objects in LibreOffice that can function as anchors:
Headings
Bookmarks - example code to create them
Tables and Frames
Sections
Images and OLE Objects
This list was copied from How do I check for broken internal links in Star Basic?. In your other question you also asked about checking for broken links, so hopefully that question is helpful.
One way to create a hyperlink is to edit the HyperLinkURL property of some text. For example, say there is a bookmark called MyBookmark. Then the following code changes the currently selected text into a hyperlink:
viewcursor = currentController.getViewCursor()
viewcursor.HyperLinkURL = "#MyBookmark"
EDIT:
Regarding which version of python to use, currently LibreOffice uses python 3 and OpenOffice uses python 2.
For debugging information, you can set a checkpoint in the Basic IDE. For python, I use the logging module. OpenOffice also has various log files but I normally do not find them helpful.
Regarding problems with python, did you try the link I posted? If so, how far did you get?
I do not think you will find many RHEL examples. Try to get it working on a desktop distro like Ubuntu first, and then adapt that approach to RHEL.

Get localized name other channel

I get the version number of the firefox from the applications.ini.
Then I hardcoded that between date #### and #### v35 is release. So now based on this and the current date and version from applications.ini I figure out the channel of other builds.
But now I want to get the localized name of the channel.
So for example I'm using beta channel and from this build I want to get the localized name of "Nightly" in chineese, so it has the chineese characters, and word for nightly in chineese. Can this also be obtained from the applications.ini? Is [App] -> Name localized in applications.ini?
This is the applications.ini method: https://ask.mozilla.org/question/705/detect-if-auroranightlybetanormal-and-get-paths/ (credits to #paa)
EDIT
i discovered this file: OS.Path.join(Services.dirsvc.get('XREExeF', Ci.nsIFile).parent.path, 'defaults', 'pref', 'channel-prefs.js')
its contents is the following:
//#line 2 "c:\builds\moz2_slave\rel-m-beta-w32_bld-00000000000\build\browser\app\profile\channel-prefs.js"
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
pref("app.update.channel", "beta");
Is this a reliable check? Does this channel-prefs.js file exist for all builds as soon as they are installed?
Is this a reliable check?
Not really. There used to be channel switcher add-ons, and in theory the user can change this pref (although at the moment this is not sufficient to really switch the channel I think).
Does this channel-prefs.js file exist for all builds as soon as they are installed?
Yes, for now. But this is an implementation detail. There is no guarantee that the file won't be moved or renamed later, or merged with another file.
Can this also be obtained from the applications.ini?
The localized name? I didn't even know there was one... I thought it was called e.g. "Nightly" in all locales like it was a (product) name. But yeah, it is theoretically possible to localize that string. It is not available from the ini file, though.
I wouldn't poke in application.ini anyway, and instead just use Services.appinfo.defaultUpdateChannel
But now I want to get the localized name of the channel.
Since you're in a running Firefox instance already (judging from your OS.File code), you should use the string bundle service to load chrome://branding/locale/brand.properties and get the brandShortName or brandFullName string from there.

Typo3 : using typoscript to modify the base-url

I am trying out TYPO3's introduction package. For that I am using Xampp on my computer.
I have installed it in a subdirectory, but since it uses "real-url", I need to modify the generated links, so that instead of http://localhost/about-typo3/ I get http://localhost/subfolder/about-typo3/
I believe it must be done via "typo-script", and from what I have read on the Internet, this line should do the job :
config.baseURL = http://localhost/subfolder/
But I don't know where I should put it. I have tried different locations, but with no apparent effect.
So what I would like to know is : am I on the good path for what I need to do, and if yes, what should I try now ?
This is a bug in the 4.6 Introduction Package. 4.7 will ship with a correct version, so you might just want to go ahead and try the Introduction Package from 4.7RC2 (Preview Releases).
For now, just choose Template in the module menu on the left. Then use the dropdown to select Constant Editor. Now choose the page HOME in the pagetree on the middle.
Now use the second dropdown to select CONFIG. There modify the topmost setting Absolute URI prefix. Input your full domain without the last slash (/). That means copy your current URL from the browser and strip /typo3/backend.php. Now save with the little save icon in the top toolbar.
This will also invalidate all caches for you (because you changed the topmost template). No need to install extra extensions or to do this manually.
Alternative you can fix the actual bug. Go to template module and select the folder TypoScript Templates / page_configuration. Now select Info/Modify instead of Constant Editor and directly above the table page.config. The click the pencil left of Setup. Find the line absRefPrefix = {$config.absRefPrefix}/. This should be around line 62 (4.7RC2). Remove the last slash (/) from that line and save. Because you are not on the topmost template, you need to clear the cache. On the topright of your screen, you can find the yellow flash icon. Click it and select Clear all caches (red flash). Now go to you website again.
A general note about (config.)baseURL. This is more a hack, because it just tells the browser to behave as if the website would be at another place. The correct way is to create correct links in first place. You should use (config.)absRefPrefix instead. To make this work in auto mode, it must be completely empty (config.absRefPrefix =).
Do not use baseURL any more. The next Introduction Package will not have this setting.
Yet another note: If you use the config.absRefPrefix, you have to include the last slash (/). The only reason why you do not have to do so above (in the constants), is because it is hardcoded in the template and thus also preventing the automatic detection to work.
If you are using different hosts, you can use typoscript conditions in your root template:
# Default:
config.baseURL = http://www.example.com/
[globalString = ENV:HTTP_HOST=sub1.example.com]
config.baseURL = http://sub1.example.com/
[global]
[globalString = ENV:HTTP_HOST=sub2.example.com]
config.baseURL = http://sub2.example.com/
[global]
if you are using introduction package. there is Constant for set the base url
Go to 'Template' and 'Constant Editor.. you can find 'Domain name for Base URL [config.domain]' .. for setting base url
also you can put the
config.baseURL = http://localhost/subfolder/
on 'Info Modify' Setup field
hope will help you .. sorry for my bad english

Resources