The Complete Developer's Guide to Latvian Diacritical Marks
How to handle ā, č, ē, ģ, ī, ķ, ļ, ņ, š, ū, ž in web development
Latvian's special characters cause real problems - broken URLs, corrupted databases, incorrectly rendered fonts. This guide has all the answers in one place.
Latvian Character Reference Table
All 33 Latvian alphabet characters with Unicode values, HTML entities and keyboard shortcuts. Click to copy.
| Character | Unicode | HTML |
|---|---|---|
| U+0100/U+0101 | Ā/ā | |
| U+010C/U+010D | Č/č | |
| U+0112/U+0113 | Ē/ē | |
| U+0122/U+0123 | Ģ/ģ | |
| U+012A/U+012B | Ī/ī | |
| U+0136/U+0137 | Ķ/ķ | |
| U+013B/U+013C | Ļ/ļ | |
| U+0145/U+0146 | Ņ/ņ | |
| U+0160/U+0161 | Š/š | |
| U+016A/U+016B | Ū/ū | |
| U+017D/U+017E | Ž/ž |
URL Slug Handling
This is the most common pain point. Latvians search with diacritics, but URLs can't contain ā, č etc. How do you properly transliterate or encode?
URL Slug Converter
maja-ar-darzu// next.config.js - no special config needed for Latvian
// Use this utility function in your project:
export function lvToSlug(text: string): string {
const map: Record<string, string> = {
ā: 'a', č: 'c', ē: 'e', ģ: 'g', ī: 'i',
ķ: 'k', ļ: 'l', ņ: 'n', š: 's', ū: 'u', ž: 'z',
Ā: 'A', Č: 'C', Ē: 'E', Ģ: 'G', Ī: 'I',
Ķ: 'K', Ļ: 'L', Ņ: 'N', Š: 'S', Ū: 'U', Ž: 'Z',
};
return text
.split('').map(c => map[c] ?? c).join('')
.toLowerCase()
.replace(/[^a-z0-9]+/g, '-')
.replace(/^-+|-+$/, '');
}
// Usage: lvToSlug('Māja ar dārzu') => 'maja-ar-darzu'Database Configuration
Incorrect database encoding leads to garbled text: ā becomes Ã, č becomes č. The fix is simple.
-- MySQL: ensure UTF-8 support for Latvian ALTER DATABASE yourdb CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; ALTER TABLE yourtable CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; -- For new tables, always specify: CREATE TABLE posts ( id INT PRIMARY KEY, title VARCHAR(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ); -- Check current table encoding: SHOW CREATE TABLE yourtable;
Font Support for Latvian
Not all Google Fonts support Latvian diacritical marks. Here are the ones that do.
Inter
100–900Pilns latviešu atbalsts. Lielisks UI fontam.
Āčēģīķļņšūž - Māja, čūska, ēdiens
Roboto
100–900Pilns atbalsts. Populārākais Google Fonts fonts.
Āčēģīķļņšūž - Māja, čūska, ēdiens
Lato
100–900Elegants, labi lasāms. Atbalsta visas LV zīmes.
Āčēģīķļņšūž - Māja, čūska, ēdiens
Open Sans
300–800Universāls, labi lasāms. Pilns atbalsts.
Āčēģīķļņšūž - Māja, čūska, ēdiens
Raleway
100–900Modernam dizainam. Atbalsta LV diakritiku.
Āčēģīķļņšūž - Māja, čūska, ēdiens
Source Sans 3
200–900Adobe fonts projekts. Pilns LV atbalsts.
Āčēģīķļņšūž - Māja, čūska, ēdiens
Form Validation
Standard `[a-z]+` regex doesn't work for Latvian names. Use these ready-made patterns.
// Regex for Latvian names (first name / last name)
const LV_NAME_REGEX = /^[A-ZĀČĒĢĪĶĻŅŠŪŽa-zāčēģīķļņšūž\s-]+$/;
// Latvian phone number (local format)
const LV_PHONE_REGEX = /^(\+371|00371)?[2678]\d{7}$/;
// Allow Latvian characters in a general text field
const LV_TEXT_REGEX = /^[A-ZĀČĒĢĪĶĻŅŠŪŽa-zāčēģīķļņšūž0-9\s.,!?;:'"()-]+$/;
// React example:
function validateName(value: string): boolean {
return LV_NAME_REGEX.test(value.trim());
}SEO and Latvian Diacritics
Google searches with and without diacritics. How to correctly set up hreflang and URL structure?
<!-- Correct hreflang for Latvian + English pages -->
<link rel="alternate" hreflang="lv" href="https://yoursite.lv/par-mums" />
<link rel="alternate" hreflang="en" href="https://yoursite.lv/en/about-us" />
<link rel="alternate" hreflang="x-default" href="https://yoursite.lv/par-mums" />
<!-- Next.js 14+ App Router (layout.tsx): -->
export async function generateMetadata() {
return {
alternates: {
canonical: 'https://yoursite.lv/par-mums',
languages: {
lv: 'https://yoursite.lv/par-mums',
en: 'https://yoursite.lv/en/about-us',
},
},
};
}Vajag palīdzību ar Latvijas web projektu?
WebWorks izstrādā mājas lapas un aplikācijas ar pilnu latviešu valodas atbalstu.