CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-mdn-data

Open Web data by the Mozilla Developer Network containing structured JSON data for web technologies including CSS properties, selectors, functions, at-rules, Web API inheritance, and localization strings used in MDN Web Docs

Pending
Quality

Pending

Does it follow best practices?

Impact

Pending

No eval scenarios have been run

SecuritybySnyk

Pending

The risk profile of this skill

Overview
Eval results
Files

l10n-data.mddocs/

Localization Data

Localization strings for CSS terminology used in MDN Web Docs across multiple languages, providing translated descriptions and explanations for CSS concepts.

Capabilities

CSS Localization Strings

Access localized strings for CSS terminology across multiple languages.

/**
 * CSS localization data with multi-language support
 */
const css: LocalizationData;

interface LocalizationData {
  [termKey: string]: LocalizationEntry;
}

interface LocalizationEntry {
  /** Language code mapped to localized string */
  [languageCode: string]: string;
}

Usage Examples:

const { l10n } = require('mdn-data');

// Get localized strings for "absolute length"
const absoluteLength = l10n.css.absoluteLength;
console.log(absoluteLength);
// Output: {
//   "de": "absolute {{cssxref(\"length\")}}",
//   "en-US": "absolute {{cssxref(\"length\")}}",
//   "fr": "une longueur (type {{cssxref(\"length\")}}) absolue",
//   "ja": "絶対的な{{cssxref(\"length\", \"長さ\")}}",
//   "ru": "абсолютная {{cssxref(\"length\")}}",
//   "zh-CN": "绝对 {{cssxref(\"length\")}}"
// }

// Get English translation for a specific term
const englishTerm = l10n.css.absoluteLength['en-US'];
console.log(englishTerm);
// Output: "absolute {{cssxref(\"length\")}}"

// Get all available languages for a term
const availableLanguages = Object.keys(l10n.css.absoluteLength);
console.log(availableLanguages);
// Output: ["de", "en-US", "fr", "ja", "ru", "zh-CN"]

Language Support

Get information about supported languages and available terms.

/**
 * Helper functions for working with localization data
 */

// Get all available language codes across all terms
function getAvailableLanguages(): string[] {
  const languages = new Set();
  Object.values(l10n.css).forEach(entry => {
    Object.keys(entry).forEach(lang => languages.add(lang));
  });
  return Array.from(languages);
}

// Get all terms available in a specific language
function getTermsForLanguage(languageCode: string): string[] {
  return Object.entries(l10n.css)
    .filter(([termKey, entry]) => languageCode in entry)
    .map(([termKey]) => termKey);
}

// Get translation for a term in a specific language with fallback
function getTranslation(termKey: string, languageCode: string, fallback: string = 'en-US'): string | undefined {
  const entry = l10n.css[termKey];
  if (!entry) return undefined;
  
  return entry[languageCode] || entry[fallback];
}

Term Categories

Access different categories of localized terms.

/**
 * Common term categories available in the localization data
 */

// Length and measurement terms
const lengthTerms = [
  'absoluteLength',
  'absoluteLength0ForNone',
  'relativeLength',
  'lengthPercentage'
];

// Color terms
const colorTerms = [
  'color',
  'colorValue',
  'namedColor',
  'systemColor'
];

// Layout terms  
const layoutTerms = [
  'blockSize',
  'inlineSize',
  'logicalProperty',
  'physicalProperty'
];

// Time and animation terms
const timeTerms = [
  'time',
  'duration',
  'animationDuration'
];

Usage Examples:

// Find all length-related terms in Japanese
const japaneseTerms = Object.entries(l10n.css)
  .filter(([termKey, entry]) => 'ja' in entry && termKey.includes('Length'))
  .map(([termKey, entry]) => ({
    term: termKey,
    translation: entry.ja
  }));

// Get localized description for computed values
const computedValue = l10n.css.computed;
console.log(computedValue['fr']);
// Output: French translation for "computed value"

// Find terms with incomplete translations (missing specific language)
const incompleteTerms = Object.entries(l10n.css)
  .filter(([termKey, entry]) => !('zh-CN' in entry))
  .map(([termKey]) => termKey);

Template String Support

Many localization strings contain template references to other MDN content.

/**
 * Template string handling for MDN cross-references
 */

// Common template patterns in localization strings:
// {{cssxref("property")}} - Link to CSS property documentation
// {{cssxref("property", "display text")}} - Link with custom display text
// <code>value</code> - Inline code formatting

// Example of processing template strings
function processTemplateString(template: string): string {
  // This would typically be handled by MDN's rendering system
  return template
    .replace(/{{cssxref\("([^"]+)"\)}}/g, '<a href="/CSS/$1">$1</a>')
    .replace(/{{cssxref\("([^"]+)",\s*"([^"]+)"\)}}/g, '<a href="/CSS/$1">$2</a>');
}

const processed = processTemplateString(l10n.css.absoluteLength['en-US']);
// Converts: "absolute {{cssxref(\"length\")}}"
// To: "absolute <a href=\"/CSS/length\">length</a>"

Data Structure Details

The localization data provides:

  • Multi-language Support: Translations for CSS terminology in multiple languages including English, German, French, Japanese, Russian, and Chinese
  • Template Integration: Strings formatted for MDN's template system with cross-references
  • Consistent Terminology: Standardized translations for CSS concepts across MDN documentation
  • Incomplete Coverage: Not all terms are available in all languages

Common Use Cases

  1. Documentation Localization: Translating CSS documentation to different languages
  2. Educational Tools: Building CSS learning resources in multiple languages
  3. Developer Tools: Providing localized error messages and help text
  4. Content Management: Managing translated content for CSS reference materials
  5. Template Processing: Converting MDN template strings to rendered HTML
  6. Translation Coverage: Identifying missing translations for specific languages

docs

api-data.md

css-data.md

index.md

l10n-data.md

tile.json