Access hidden preferences in translators

14 views
Skip to first unread message

linxz...@gmail.com

unread,
Aug 16, 2020, 11:44:00 PM8/16/20
to zotero-dev

Hi there.

In this [post](https://groups.google.com/g/zotero-dev/c/5p3Fewsg9A8/m/iDrBUhefBgAJ),  I was told in the web translator code, I can use ` Z.getHiddenPref() ` to access Translator Preference.  I have a problem when I try these codes in a translator, so I create a new post for help.

At first, I created a new preference `translators.CNKI` with a simple value "OK". Everything is OK when I explore my code in the translator editor.  The preference value is displayed in the output window 

```javascript
var p = Z.getHiddenPref("CNKI");   
Z.debug(p);
```

Then I update my code in a translator, in the debug output of Zotero connector. The output preference value is `(3)(+0000001): ===>null<=== (object)`. I also tried preferences on this [page](https://www.zotero.org/support/preferences/hidden_preferences#translator_preferences1). The value is still `null`.  

Is it caused by the sandbox? or I use the code in a wrong way?





Dan Stillman

unread,
Aug 16, 2020, 11:46:02 PM8/16/20
to zoter...@googlegroups.com
On 8/16/20 11:44 PM, linxz...@gmail.com wrote:
> At first, I created a new preference `translators.CNKI` with a simple
> value "OK". Everything is OK when I explore my code in the translator
> editor.  The preference value is displayed in the output window
>
> ```javascript
> var p = Z.getHiddenPref("CNKI");
> Z.debug(p);
> ```
>
> Then I update my code in a translator, in the debug output of Zotero
> connector. The output preference value is `(3)(+0000001): ===>null<===
> (object)`. I also tried preferences on this
> [page](https://www.zotero.org/support/preferences/hidden_preferences#translator_preferences1).
> The value is still `null`.
>
> Is it caused by the sandbox? or I use the code in a wrong way?

For it to work in the Connector, you need to set it in the Connector
hidden preferences, not the client's.

linxz...@gmail.com

unread,
Aug 17, 2020, 9:58:53 AM8/17/20
to zotero-dev
I have added a preference in zotero connector
2020-08-17_21-56.png
But the result in debug log is still null
2020-08-17_21-57.png

Dan Stillman

unread,
Aug 17, 2020, 1:58:30 PM8/17/20
to zoter...@googlegroups.com
On 8/17/20 9:58 AM, linxz...@gmail.com wrote:
> I have added a preference in zotero connector
>
> But the result in debug log is still null

See the documentation I linked to. The preferences have to start with
"translators.".
Reply all
Reply to author
Forward
0 new messages