Skip to content

Conversation

LawData-user
Copy link

Translator for Jade.io legal database in Australia.

Translator for Jade.io legal database in Australia.
@alex-ter
Copy link
Contributor

alex-ter commented May 30, 2025

I haven't checked the code in detail, but isn't this a duplicate of #3452? In any case, it looks like you're using some old translator template version, these days the functions should be async and there are other differences. If you haven't done that yet and you're keen on writing it yourself, I'd suggest you to start here: https://www.zotero.org/support/dev/translators. The Scaffold from a current Zotero version will generate the proper template for you and you can go from there. If you just need the translator, I'd maybe suggest you to submit a request instead (https://github.com/zotero/translators/issues) and wait for someone to pick it up.

@@ -0,0 +1,117 @@
{
"translatorID": "c7e07d17-cc0b-4f6c-b12a-6f3a9de0410b", // generate with `uuidgen` if needed
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This happens to be a valid UUID, but you shouldn't use ChatGPT-generated UUIDs (and the comment makes this an invalid translator). Remove the comment, open the translator in Scaffold (Tools -> Translator Editor), and click Generate next to the Translator ID field.

{
"translatorID": "c7e07d17-cc0b-4f6c-b12a-6f3a9de0410b", // generate with `uuidgen` if needed
"label": "JADE Case Extractor",
"creator": "Custom for Australian case law",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be your name

@@ -0,0 +1,117 @@
{
"translatorID": "c7e07d17-cc0b-4f6c-b12a-6f3a9de0410b", // generate with `uuidgen` if needed
"label": "JADE Case Extractor",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"label": "JADE Case Extractor",
"label": "JADE",

And rename the file to JADE.js.



function detectWeb(doc, url) {
if (url.includes("jade.io/article/")) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will always be true because of the target regex, and we want something more specific that matches on the contents of the page, like a check that doc.title conforms to the format we expect below.

Comment on lines +27 to +39
let titleElement = doc.querySelector("title");
if (titleElement) {
let fullTitle = titleElement.innerText.trim();
let titleMatch = fullTitle.match(/^(.+?)\s\[(\d{4})\]\s+(\w+)\s+(\d+)/);
if (titleMatch) {
newItem.caseName = titleMatch[1];
newItem.dateDecided = titleMatch[2];
newItem.court = titleMatch[3];
newItem.docketNumber = titleMatch[4];
} else {
Zotero.debug("Failed to parse case details from <title> tag.");
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
let titleElement = doc.querySelector("title");
if (titleElement) {
let fullTitle = titleElement.innerText.trim();
let titleMatch = fullTitle.match(/^(.+?)\s\[(\d{4})\]\s+(\w+)\s+(\d+)/);
if (titleMatch) {
newItem.caseName = titleMatch[1];
newItem.dateDecided = titleMatch[2];
newItem.court = titleMatch[3];
newItem.docketNumber = titleMatch[4];
} else {
Zotero.debug("Failed to parse case details from <title> tag.");
}
}
let fullTitle = doc.title;
let titleMatch = fullTitle.match(/^(.+?)\s\[(\d{4})\]\s+(\w+)\s+(\d+)/);
if (titleMatch) {
newItem.caseName = titleMatch[1];
newItem.dateDecided = titleMatch[2];
newItem.court = titleMatch[3];
newItem.docketNumber = titleMatch[4];
}

newItem.attachments.push({
document: doc,
title: "Snapshot",
mimeType: "text/html"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can remove this line when passing a document

// Standardise URL
newItem.url = url
.replace(/^http:\/\//, 'https://')
.replace(/^(https:\/\/www)\d/, '$1');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This shouldn't be necessary - just set the URL to url. Sometimes it makes sense to clean query parameters from the URL, but I can't say more without seeing a test case.

// Add remaining citations to extra
let extraCitations = parts.slice(2).join("; ");
if (extraCitations) {
newItem.extra = "Additional citations: " + extraCitations;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These should be notes, or not added at all.

newItem.attachments.push({
title: "Original Document",
url: href,
mimeType: isPDF ? "application/pdf" : "application/octet-stream",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it's not a PDF, what is it?

title: "Original Document",
url: href,
mimeType: isPDF ? "application/pdf" : "application/octet-stream",
snapshot: false
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove

@AbeJellinek
Copy link
Member

Yeah, I mean there's nothing wrong with this structure if the translator doesn't do anything that actually requires async (and this one doesn't), but we should at the very least move doWeb() above scrape() and try to implement support for multiples (search pages).

russellbrenner added a commit to russellbrenner/translators that referenced this pull request Aug 31, 2025
- Comprehensive translator for Australian case law and legislation  
- Supports both High Court and state/territory courts
- Robust citation parsing with multiple fallbacks
- Handles neutral citations and parallel reports
- Includes proper AGPL licensing and test cases
- Significantly more robust than existing PR zotero#3453
russellbrenner added a commit to russellbrenner/translators that referenced this pull request Aug 31, 2025
## Enhanced Features & Documentation
- **Comprehensive JSDoc comments**: Full API documentation for all functions
- **Robust citation parsing**: Handles neutral citations, parallel reports, and edge cases
- **Dual document support**: Cases AND legislation (Acts, Regulations, Rules)
- **Professional error handling**: Multiple fallback strategies throughout
- **ESLint compliance**: Clean code following Zotero standards
- **Extensive test coverage**: Real-world test cases for various document types

## Technical Improvements Over Existing PR zotero#3453
- 536 lines vs 117 lines (4.5x more comprehensive)
- 15+ documented helper functions vs basic regex parsing
- Proper AGPL licensing and extensive test cases
- Court name standardisation and date normalisation
- OpenGraph metadata extraction with fallbacks
- PDF attachment detection and section-specific URL handling

## Code Quality Standards
- Full JSDoc documentation with parameter types and return values
- Modular design with single-responsibility functions  
- Comprehensive error handling and input validation
- AGLC-compliant citation formatting for Australian legal standards
- Professional-grade implementation ready for production use

This translator provides robust, well-documented support for Australian legal researchers using JADE.io with Zotero.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants