-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathi18n.js
More file actions
709 lines (661 loc) · 33.6 KB
/
Copy pathi18n.js
File metadata and controls
709 lines (661 loc) · 33.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
/* Internacionalização da interface.
*
* Uso no HTML:
* data-i18n="chave" -> textContent
* data-i18n-html="chave" -> innerHTML (quando o texto tem <b>, <span>...)
* data-i18n-title="chave" -> atributo title
* data-i18n-ph="chave" -> atributo placeholder
*
* Uso no JS: I18n.t('chave', { nome: valor })
* Um valor do dicionário pode ser string (com {marcadores}) ou função(params).
*/
const I18n = (() => {
const LANGS = [
{ id: 'pt-BR', short: 'PT', label: 'Português (Brasil)' },
{ id: 'en', short: 'EN', label: 'English' }
];
const DICT = {
// ================================================================
'pt-BR': {
'html.lang': 'pt-BR',
// ---------- barra superior ----------
'tb.dbName.title': 'Nome do banco / projeto',
'tb.dbName.value': 'NovoBanco',
'tb.dialect.title': 'Dialeto SQL de saída',
'tb.import': 'Importar banco',
'tb.import.title': 'Importar de um banco existente (Ctrl+I)',
'tb.newTable': 'Nova tabela',
'tb.newTable.title': 'Nova tabela (Ctrl+Enter)',
'tb.sql': 'Gerar SQL',
'tb.sql.title': 'Gerar SQL (Ctrl+G)',
'tb.undo.title': 'Desfazer (Ctrl+Z)',
'tb.redo.title': 'Refazer (Ctrl+Y)',
'tb.layout': 'Organizar',
'tb.layout.title': 'Organizar diagrama (Ctrl+L repete o último, Ctrl+Shift+L abre)',
'tb.fit.title': 'Ajustar à tela (Ctrl+0)',
'tb.open.title': 'Abrir projeto (.dbdiag.json)',
'tb.save.title': 'Salvar projeto (Ctrl+S)',
'tb.exportImg.title': 'Exportar imagem (SVG/PNG)',
'tb.theme.title': 'Alternar tema',
'tb.lang.title': 'Switch to English',
'tb.env': p => `pyodbc ${p.pyodbc} · ${p.drivers} driver(s) SQL Server · Access ${p.access}`,
'tb.env.noPyodbc': 'pyodbc ausente',
// ---------- tabelas no canvas ----------
'node.pk': 'Chave primária',
'node.fk': 'Chave estrangeira',
'node.unique': 'Único',
'node.nullable': 'Aceita nulo',
'node.addField': 'Adicionar campo',
'node.more': 'Mais opções',
'node.addFieldBtn': '+ adicionar campo',
// ---------- painel esquerdo ----------
'side.structure': 'Estrutura',
'side.expandAll': 'Expandir/recolher tudo',
'side.search': 'Buscar tabela ou campo...',
'side.notFound': 'Nada encontrado.',
'side.empty': 'Nenhuma tabela ainda.',
// ---------- canvas ----------
'es.title': 'Nenhuma tabela no diagrama',
'es.text': 'Importe a estrutura de um banco existente (.accdb ou SQL Server), carregue um projeto salvo, ou comece do zero criando uma tabela.',
'es.import': 'Importar banco existente',
'es.new': 'Criar tabela',
'es.demo': 'Carregar exemplo',
'zoom.in': 'Aproximar',
'zoom.out': 'Afastar',
'zoom.reset': '100%',
'hint.pan': '<b>Arraste</b> o fundo p/ mover',
'hint.zoom': '<b>Roda</b> p/ zoom',
'hint.link': '<b>Arraste o ponto</b> de um campo p/ criar relação',
'hint.del': '<b>Del</b> apaga',
// ---------- inspetor ----------
'insp.tab.props': 'Propriedades',
'insp.tab.rels': 'Relações',
'insp.summary': 'Resumo do modelo',
'insp.tables': 'Tabelas',
'insp.fields': 'Campos',
'insp.rels': 'Relações',
'insp.withPk': 'Com PK',
'insp.baseline': p => `Base de comparação carregada: <b>${p.name}</b>. O script de atualização usará esse estado como origem.`,
'insp.warning': 'Atenção',
'insp.noPk': p => `Sem chave primária: ${p.list}`,
'insp.tips': 'Dicas',
'insp.tips.body': '• Clique numa tabela ou campo para editar aqui.<br>• Arraste o <b>ponto azul</b> de um campo até outro para criar a relação (FK).<br>• <b>Shift + arrastar</b> no fundo seleciona várias tabelas.<br>• Botão direito abre o menu de ações.',
'insp.multi': p => `${p.n} tabelas selecionadas`,
'insp.color': 'Cor',
'insp.alignLeft': 'Alinhar à esquerda',
'insp.alignTop': 'Alinhar ao topo',
'insp.distV': 'Distribuir vertical',
'insp.delTables': 'Excluir tabelas',
'insp.table': 'Tabela',
'insp.name': 'Nome',
'insp.schema': 'Schema / dono',
'insp.description': 'Descrição',
'insp.table.descPh': 'Para que serve esta tabela...',
'insp.fieldsCount': p => `Campos (${p.n})`,
'insp.addField': '+ campo',
'insp.indexes': 'Índices',
'insp.addIndex': '+ índice',
'insp.noIndex': 'Nenhum índice além da chave primária.',
'insp.unique': 'único',
'insp.relsCount': p => `Relações (${p.n})`,
'insp.noRels': 'Nenhuma relação.',
'insp.actions': 'Ações',
'insp.duplicate': 'Duplicar',
'insp.center': 'Centralizar',
'insp.delTable': 'Excluir tabela',
'insp.idxPrompt': 'Campos do índice (separados por vírgula):',
'insp.idxUnique': 'Índice único?',
'insp.field': 'Campo',
'insp.type': 'Tipo',
'insp.length': 'Tamanho',
'insp.precision': 'Precisão',
'insp.scale': 'Escala',
'insp.maxHint': 'Use -1 para MAX / TEXT.',
'insp.pk': 'Chave primária',
'insp.notNull': 'Obrigatório',
'insp.uniqueChk': 'Único',
'insp.identity': 'Auto incremento',
'insp.default': 'Valor padrão (expressão SQL)',
'insp.defaultPh': "ex.: 0, GETDATE(), 'Pendente'",
'insp.check': 'Regra CHECK (opcional)',
'insp.checkPh': 'ex.: Valor >= 0',
'insp.fieldDesc': 'Descrição do campo',
'insp.fieldDescPh': 'O que este campo armazena...',
'insp.nativeType': p => `Tipo original no banco de origem: <span class="mono">${p.type}</span>`,
'insp.fieldRels': p => `Relações deste campo (${p.n})`,
'insp.noFieldRels': 'Nenhuma. Arraste o ponto azul deste campo até a chave de outra tabela.',
'insp.addBelow': '+ campo abaixo',
'insp.delField': 'Excluir campo',
'insp.copySuffix': '_copia',
'insp.rel': 'Relação (chave estrangeira)',
'insp.relHead': p => `<b>${p.from}</b> (muitos) ➜ <b>${p.to}</b> (um)`,
'insp.relHint': 'A tabela da esquerda guarda a chave estrangeira.',
'insp.constraintName': 'Nome da constraint',
'insp.fieldIn': p => `Campo em ${p.table}`,
'insp.addPair': '+ par de campos (chave composta)',
'insp.swapRel': 'Inverter direção',
'insp.goTo': p => `Ir p/ ${p.table}`,
'insp.delRel': 'Excluir relação',
'insp.allRels': p => `Todas as relações (${p.n})`,
'insp.noRelsYet': 'Nenhuma relação ainda.<br><br>Arraste o ponto azul que aparece ao lado de um campo até a chave primária de outra tabela.',
// ---------- importar ----------
'imp.title': 'Importar estrutura de banco existente',
'imp.tab.access': 'Microsoft Access',
'imp.tab.mssql': 'SQL Server',
'imp.tab.file': 'Projeto salvo',
'imp.acc.drop': '<b>Solte aqui</b> o arquivo .accdb / .mdb ou clique para escolher',
'imp.acc.dropSub': 'O arquivo é lido localmente pelo servidor e descartado em seguida.',
'imp.acc.orPath': 'Ou informe o caminho no disco',
'imp.acc.pathPh': 'C:\\caminho\\meubanco.accdb',
'imp.acc.pwd': 'Senha do banco (se houver)',
'imp.acc.pwdPh': 'opcional',
'imp.acc.views': 'Incluir consultas',
'imp.acc.ok': 'Driver do Access detectado. Relações são lidas via ODBC e, se necessário, de <span class="mono">MSysRelationships</span>.',
'imp.acc.missing': '<b style="color:#fca5a5">Driver do Access não encontrado.</b> Instale o "Microsoft Access Database Engine 2016 Redistributable" na mesma arquitetura do Python (64 bits) para importar .accdb.',
'imp.acc.chosen': p => `${p.size} MB — clique em Importar`,
'imp.acc.need': 'Escolha um arquivo .accdb ou informe o caminho.',
'imp.acc.reading': p => `Lendo ${p.file}...`,
'imp.acc.readingPath': 'Lendo arquivo...',
'imp.ms.paste': 'Cole aqui um link / connection string (opcional)',
'imp.ms.pastePh': 'Server=tcp:meuservidor,1433;Database=Vendas;User Id=sa;Password=... | meuservidor\\SQLEXPRESS',
'imp.ms.server': 'Servidor',
'imp.ms.serverPh': 'localhost\\SQLEXPRESS ou host,1433',
'imp.ms.database': 'Banco',
'imp.ms.databasePh': 'nome do banco',
'imp.ms.auth': 'Autenticação',
'imp.ms.authWin': 'Windows (integrada)',
'imp.ms.authSql': 'SQL Server (usuário/senha)',
'imp.ms.driver': 'Driver ODBC',
'imp.ms.noDriver': 'nenhum driver encontrado',
'imp.ms.user': 'Usuário',
'imp.ms.pass': 'Senha',
'imp.ms.trust': 'Confiar no certificado',
'imp.ms.system': 'Incluir schemas de sistema',
'imp.ms.schemas': 'Filtrar schemas (separados por vírgula, vazio = todos)',
'imp.ms.schemasPh': 'dbo, vendas',
'imp.ms.test': 'Testar conexão',
'imp.ms.listDbs': 'Listar bancos',
'imp.ms.privacy': 'A senha é usada apenas nesta máquina para abrir a conexão ODBC e não é gravada em disco.',
'imp.ms.parsed': 'Dados extraídos do texto colado. Confira e clique em Testar conexão.',
'imp.ms.connecting': 'Conectando...',
'imp.ms.connected': p => `Conectado como <b>${p.login}</b> — banco <b>${p.db}</b><br><span class="small mono">${p.version}</span>`,
'imp.ms.listing': 'Listando bancos...',
'imp.ms.listed': p => `${p.n} banco(s) encontrados: ${p.list}`,
'imp.ms.reading': 'Lendo estrutura do banco...',
'imp.file.drop': '<b>Solte</b> um arquivo <span class="mono">.dbdiag.json</span> ou clique para escolher',
'imp.file.example': 'Exemplo',
'imp.file.loadDemo': 'Carregar banco de exemplo (loja)',
'imp.file.need': 'Escolha um arquivo .dbdiag.json.',
'imp.merge': 'Mesclar com o diagrama atual',
'imp.cancel': 'Cancelar',
'imp.go': 'Importar',
'imp.going': 'Importando...',
// ---------- SQL ----------
'sql.title': 'Geração de código SQL',
'sql.tab.create': 'CREATE TABLE',
'sql.tab.update': 'Atualização (ALTER)',
'sql.tab.seed': 'Dados fictícios',
'sql.opt.fk': 'Chaves estrangeiras',
'sql.opt.idx': 'Índices',
'sql.opt.com': 'Descrições dos campos',
'sql.opt.ifNot': 'IF NOT EXISTS',
'sql.opt.drop': 'Incluir DROP',
'sql.diff.intro': 'Compara o estado do banco importado (base) com o diagrama atual e gera o script de migração.',
'sql.diff.with': p => `Comparando com <b>${p.name}</b> (estado importado) → diagrama atual.`,
'sql.diff.none': 'Nenhum banco foi importado nesta sessão; tudo será tratado como <b>novo</b>. Importe um banco para gerar um ALTER incremental.',
'sql.opt.allowDrop': 'Permitir DROP de colunas/tabelas removidas',
'sql.seed.rows': 'Linhas por tabela',
'sql.seed.seed': 'Semente (mesma semente = mesmos dados)',
'sql.seed.batch': 'Linhas por INSERT',
'sql.opt.identIns': 'Incluir colunas IDENTITY (SET IDENTITY_INSERT)',
'sql.opt.truncate': 'Limpar tabelas antes (DELETE)',
'sql.seed.hint': 'Os valores são inferidos pelo tipo <b>e pelo nome</b> do campo (CPF/CNPJ válidos, e-mails, nomes, cidades, datas, preços...). Chaves estrangeiras recebem apenas valores existentes na tabela pai.',
'sql.generating': '-- gerando...',
'sql.copy': 'Copiar',
'sql.download': 'Baixar .sql',
'sql.close': 'Fechar',
'sql.meta': p => `${p.lines} linhas · ${p.kb} KB · ${p.dialect}`,
'sql.copied': 'SQL copiado para a área de transferência.',
'sql.needTables': 'Crie ou importe tabelas primeiro.',
'sql.error': p => `-- ERRO: ${p.msg}`,
// ---------- exportar imagem ----------
'img.title': 'Exportar imagem',
'img.format': 'Formato',
'img.svg': 'SVG (vetorial)',
'img.scale': 'Escala (PNG)',
'img.light': 'Fundo claro (melhor p/ imprimir)',
'img.types': 'Mostrar tipos de dados',
'img.go': 'Exportar',
'img.nothing': 'Nada para exportar.',
'img.doneSvg': 'Diagrama exportado em SVG.',
'img.donePng': 'Diagrama exportado em PNG.',
'img.failPng': 'Falha ao gerar o PNG.',
'img.footer': p => `${p.name} — ${p.tables} tabelas, ${p.rels} relações`,
// ---------- layouts ----------
'lay.head': 'Organizar diagrama',
'lay.spacing': p => `Espaçamento <b id="gapVal">${p.gap}</b> px`,
'lay.fitAfter': 'Ajustar à tela depois',
'lay.compare': 'Comparar todos os layouts',
'lay.cmp.title': 'Comparação de layouts',
'lay.cmp.intro': 'Cada layout foi calculado com o modelo atual. <b>Cruzamentos</b> são linhas de relação que se cortam; <b>linhas sobre tabelas</b> são conexões que passam por cima de uma caixa. Quanto menor, mais limpa fica a leitura.',
'lay.cmp.layout': 'Layout',
'lay.cmp.crossings': 'Cruzamentos',
'lay.cmp.overlaps': 'Linhas sobre tabelas',
'lay.cmp.apply': 'Aplicar',
'lay.cmp.best': 'melhor',
'lay.noTables': 'Nenhuma tabela para organizar.',
'lay.noCompare': 'Nenhuma tabela para comparar.',
'lay.result': p =>
`${p.auto ? 'Melhor layout: ' : ''}${p.name} — ${p.crossings} ` +
`cruzamento${p.crossings === 1 ? '' : 's'}, ${p.overlaps} ` +
`linha${p.overlaps === 1 ? '' : 's'} sobre tabelas (${p.ms} ms)`,
'lay.mode.auto.name': 'Automático (melhor)',
'lay.mode.auto.desc': 'Testa vários e escolhe o com menos cruzamentos',
'lay.mode.layered.name': 'Camadas',
'lay.mode.layered.desc': 'Hierarquia por dependência: tabelas pai à esquerda',
'lay.mode.radial.name': 'Estrela',
'lay.mode.radial.desc': 'A tabela mais conectada no centro, as demais em anéis',
'lay.mode.fill.name': 'Preencher a tela',
'lay.mode.fill.desc': 'Ocupa todo o retângulo visível, mantendo vizinhos juntos',
'lay.mode.force.name': 'Orgânico',
'lay.mode.force.desc': 'Simulação de forças: agrupa o que é relacionado',
'lay.mode.circle.name': 'Círculo',
'lay.mode.circle.desc': 'Todas as tabelas em um anel único',
'lay.mode.tree.name': 'Árvore',
'lay.mode.tree.desc': 'Hierarquia de cima para baixo',
'lay.mode.grid.name': 'Grade alfabética',
'lay.mode.grid.desc': 'Ordem alfabética, para encontrar tabelas rapidamente',
// ---------- menu de contexto ----------
'ctx.rename': '✎ Renomear',
'ctx.addField': '+ Adicionar campo',
'ctx.duplicate': '⧉ Duplicar tabela',
'ctx.center': '⌖ Centralizar',
'ctx.toFront': '⇱ Enviar para o início',
'ctx.delTable': '🗑 Excluir tabela',
'ctx.editPanel': '✎ Editar no painel',
'ctx.pk': '🔑 Chave primária',
'ctx.notNull': 'Obrigatório (NOT NULL)',
'ctx.unique': '★ Único',
'ctx.identity': 'Auto incremento',
'ctx.fieldBelow': '+ Campo abaixo',
'ctx.delField': '🗑 Excluir campo',
'ctx.editRel': '✎ Editar relação',
'ctx.swapRel': '⇄ Inverter direção',
'ctx.delRel': '🗑 Excluir relação',
'ctx.newTableHere': '+ Nova tabela aqui',
'ctx.relayout': '⌗ Reorganizar (último layout)',
'ctx.pickLayout': '▤ Escolher layout...',
'ctx.fit': '⤢ Ajustar à tela',
'ctx.import': '⬇ Importar banco',
'ctx.sql': '⚙ Gerar SQL',
// ---------- mensagens gerais ----------
'msg.imported': p => `Importado: ${p.tables} tabelas e ${p.rels} relações.`,
'msg.noRelsFound': 'Nenhuma relação foi encontrada no banco de origem. No Access, as relações só são lidas se estiverem definidas em "Relacionamentos".',
'msg.projectLoaded': p => `Projeto carregado: ${p.name}`,
'msg.invalidFile': p => `Arquivo inválido: ${p.msg}`,
'msg.demoLoaded': 'Banco de exemplo carregado.',
'msg.projectSaved': 'Projeto salvo em .dbdiag.json',
'msg.restored': p => `Sessão anterior restaurada (${p.when}).`,
'msg.envFail': p => `Não foi possível ler o ambiente do servidor: ${p.msg}`,
'msg.badResponse': p => `Resposta inválida do servidor: ${p.text}`,
'msg.relWarning': p => `Relação criada, mas ${p.table}.${p.column} não é chave primária nem única — o banco pode recusar a FK.`,
'msg.newTableName': 'NovaTabela',
'msg.newFieldName': 'Campo',
'msg.pkDescription': 'Chave primária',
'confirm.delTables': p => `Excluir ${p.n} tabela(s)?`,
'confirm.delTable': p => `Excluir a tabela "${p.name}" e suas relações?`,
'confirm.delSelected': p => `Excluir ${p.n} tabelas e suas relações?`
},
// ================================================================
'en': {
'html.lang': 'en',
// ---------- top bar ----------
'tb.dbName.title': 'Database / project name',
'tb.dbName.value': 'NewDatabase',
'tb.dialect.title': 'Target SQL dialect',
'tb.import': 'Import database',
'tb.import.title': 'Import from an existing database (Ctrl+I)',
'tb.newTable': 'New table',
'tb.newTable.title': 'New table (Ctrl+Enter)',
'tb.sql': 'Generate SQL',
'tb.sql.title': 'Generate SQL (Ctrl+G)',
'tb.undo.title': 'Undo (Ctrl+Z)',
'tb.redo.title': 'Redo (Ctrl+Y)',
'tb.layout': 'Arrange',
'tb.layout.title': 'Arrange diagram (Ctrl+L repeats the last one, Ctrl+Shift+L opens)',
'tb.fit.title': 'Fit to screen (Ctrl+0)',
'tb.open.title': 'Open project (.dbdiag.json)',
'tb.save.title': 'Save project (Ctrl+S)',
'tb.exportImg.title': 'Export image (SVG/PNG)',
'tb.theme.title': 'Toggle theme',
'tb.lang.title': 'Mudar para português',
'tb.env': p => `pyodbc ${p.pyodbc} · ${p.drivers} SQL Server driver(s) · Access ${p.access}`,
'tb.env.noPyodbc': 'pyodbc missing',
// ---------- tables on the canvas ----------
'node.pk': 'Primary key',
'node.fk': 'Foreign key',
'node.unique': 'Unique',
'node.nullable': 'Nullable',
'node.addField': 'Add field',
'node.more': 'More options',
'node.addFieldBtn': '+ add field',
// ---------- left panel ----------
'side.structure': 'Structure',
'side.expandAll': 'Expand/collapse all',
'side.search': 'Search table or field...',
'side.notFound': 'Nothing found.',
'side.empty': 'No tables yet.',
// ---------- canvas ----------
'es.title': 'No tables in the diagram',
'es.text': 'Import the structure of an existing database (.accdb or SQL Server), open a saved project, or start from scratch by creating a table.',
'es.import': 'Import existing database',
'es.new': 'Create table',
'es.demo': 'Load example',
'zoom.in': 'Zoom in',
'zoom.out': 'Zoom out',
'zoom.reset': '100%',
'hint.pan': '<b>Drag</b> the background to pan',
'hint.zoom': '<b>Wheel</b> to zoom',
'hint.link': '<b>Drag the dot</b> next to a field to create a relationship',
'hint.del': '<b>Del</b> deletes',
// ---------- inspector ----------
'insp.tab.props': 'Properties',
'insp.tab.rels': 'Relationships',
'insp.summary': 'Model summary',
'insp.tables': 'Tables',
'insp.fields': 'Fields',
'insp.rels': 'Relationships',
'insp.withPk': 'With PK',
'insp.baseline': p => `Comparison baseline loaded: <b>${p.name}</b>. The migration script will use that state as its source.`,
'insp.warning': 'Heads-up',
'insp.noPk': p => `No primary key: ${p.list}`,
'insp.tips': 'Tips',
'insp.tips.body': '• Click a table or field to edit it here.<br>• Drag the <b>blue dot</b> from one field onto another to create a relationship (FK).<br>• <b>Shift + drag</b> on the background selects several tables.<br>• Right-click opens the action menu.',
'insp.multi': p => `${p.n} tables selected`,
'insp.color': 'Color',
'insp.alignLeft': 'Align left',
'insp.alignTop': 'Align top',
'insp.distV': 'Distribute vertically',
'insp.delTables': 'Delete tables',
'insp.table': 'Table',
'insp.name': 'Name',
'insp.schema': 'Schema / owner',
'insp.description': 'Description',
'insp.table.descPh': 'What this table is for...',
'insp.fieldsCount': p => `Fields (${p.n})`,
'insp.addField': '+ field',
'insp.indexes': 'Indexes',
'insp.addIndex': '+ index',
'insp.noIndex': 'No indexes other than the primary key.',
'insp.unique': 'unique',
'insp.relsCount': p => `Relationships (${p.n})`,
'insp.noRels': 'No relationships.',
'insp.actions': 'Actions',
'insp.duplicate': 'Duplicate',
'insp.center': 'Center',
'insp.delTable': 'Delete table',
'insp.idxPrompt': 'Index fields (comma separated):',
'insp.idxUnique': 'Unique index?',
'insp.field': 'Field',
'insp.type': 'Type',
'insp.length': 'Length',
'insp.precision': 'Precision',
'insp.scale': 'Scale',
'insp.maxHint': 'Use -1 for MAX / TEXT.',
'insp.pk': 'Primary key',
'insp.notNull': 'Required',
'insp.uniqueChk': 'Unique',
'insp.identity': 'Auto increment',
'insp.default': 'Default value (SQL expression)',
'insp.defaultPh': "e.g. 0, GETDATE(), 'Pending'",
'insp.check': 'CHECK rule (optional)',
'insp.checkPh': 'e.g. amount >= 0',
'insp.fieldDesc': 'Field description',
'insp.fieldDescPh': 'What this field stores...',
'insp.nativeType': p => `Original type in the source database: <span class="mono">${p.type}</span>`,
'insp.fieldRels': p => `Relationships for this field (${p.n})`,
'insp.noFieldRels': 'None. Drag the blue dot from this field onto a key in another table.',
'insp.addBelow': '+ field below',
'insp.delField': 'Delete field',
'insp.copySuffix': '_copy',
'insp.rel': 'Relationship (foreign key)',
'insp.relHead': p => `<b>${p.from}</b> (many) ➜ <b>${p.to}</b> (one)`,
'insp.relHint': 'The table on the left holds the foreign key.',
'insp.constraintName': 'Constraint name',
'insp.fieldIn': p => `Field in ${p.table}`,
'insp.addPair': '+ field pair (composite key)',
'insp.swapRel': 'Reverse direction',
'insp.goTo': p => `Go to ${p.table}`,
'insp.delRel': 'Delete relationship',
'insp.allRels': p => `All relationships (${p.n})`,
'insp.noRelsYet': 'No relationships yet.<br><br>Drag the blue dot that appears next to a field onto the primary key of another table.',
// ---------- import ----------
'imp.title': 'Import structure from an existing database',
'imp.tab.access': 'Microsoft Access',
'imp.tab.mssql': 'SQL Server',
'imp.tab.file': 'Saved project',
'imp.acc.drop': '<b>Drop</b> a .accdb / .mdb file here, or click to browse',
'imp.acc.dropSub': 'The file is read locally by the server and discarded right after.',
'imp.acc.orPath': 'Or type a path on disk',
'imp.acc.pathPh': 'C:\\path\\mydatabase.accdb',
'imp.acc.pwd': 'Database password (if any)',
'imp.acc.pwdPh': 'optional',
'imp.acc.views': 'Include queries',
'imp.acc.ok': 'Access driver detected. Relationships are read over ODBC and, when needed, from <span class="mono">MSysRelationships</span>.',
'imp.acc.missing': '<b style="color:#fca5a5">Access driver not found.</b> Install the "Microsoft Access Database Engine 2016 Redistributable" matching your Python architecture (64-bit) to import .accdb files.',
'imp.acc.chosen': p => `${p.size} MB — click Import`,
'imp.acc.need': 'Choose a .accdb file or type a path.',
'imp.acc.reading': p => `Reading ${p.file}...`,
'imp.acc.readingPath': 'Reading file...',
'imp.ms.paste': 'Paste a link / connection string here (optional)',
'imp.ms.pastePh': 'Server=tcp:myserver,1433;Database=Sales;User Id=sa;Password=... | myserver\\SQLEXPRESS',
'imp.ms.server': 'Server',
'imp.ms.serverPh': 'localhost\\SQLEXPRESS or host,1433',
'imp.ms.database': 'Database',
'imp.ms.databasePh': 'database name',
'imp.ms.auth': 'Authentication',
'imp.ms.authWin': 'Windows (integrated)',
'imp.ms.authSql': 'SQL Server (user/password)',
'imp.ms.driver': 'ODBC driver',
'imp.ms.noDriver': 'no driver found',
'imp.ms.user': 'User',
'imp.ms.pass': 'Password',
'imp.ms.trust': 'Trust server certificate',
'imp.ms.system': 'Include system schemas',
'imp.ms.schemas': 'Filter schemas (comma separated, empty = all)',
'imp.ms.schemasPh': 'dbo, sales',
'imp.ms.test': 'Test connection',
'imp.ms.listDbs': 'List databases',
'imp.ms.privacy': 'The password is used on this machine only to open the ODBC connection and is never written to disk.',
'imp.ms.parsed': 'Details extracted from the pasted text. Check them and click Test connection.',
'imp.ms.connecting': 'Connecting...',
'imp.ms.connected': p => `Connected as <b>${p.login}</b> — database <b>${p.db}</b><br><span class="small mono">${p.version}</span>`,
'imp.ms.listing': 'Listing databases...',
'imp.ms.listed': p => `${p.n} database(s) found: ${p.list}`,
'imp.ms.reading': 'Reading the database structure...',
'imp.file.drop': '<b>Drop</b> a <span class="mono">.dbdiag.json</span> file here, or click to browse',
'imp.file.example': 'Example',
'imp.file.loadDemo': 'Load the example database (shop)',
'imp.file.need': 'Choose a .dbdiag.json file.',
'imp.merge': 'Merge into the current diagram',
'imp.cancel': 'Cancel',
'imp.go': 'Import',
'imp.going': 'Importing...',
// ---------- SQL ----------
'sql.title': 'SQL code generation',
'sql.tab.create': 'CREATE TABLE',
'sql.tab.update': 'Migration (ALTER)',
'sql.tab.seed': 'Fake data',
'sql.opt.fk': 'Foreign keys',
'sql.opt.idx': 'Indexes',
'sql.opt.com': 'Field descriptions',
'sql.opt.ifNot': 'IF NOT EXISTS',
'sql.opt.drop': 'Include DROP',
'sql.diff.intro': 'Compares the imported database (baseline) with the current diagram and writes the migration script.',
'sql.diff.with': p => `Comparing <b>${p.name}</b> (imported state) → current diagram.`,
'sql.diff.none': 'No database was imported in this session, so everything is treated as <b>new</b>. Import a database to get an incremental ALTER script.',
'sql.opt.allowDrop': 'Allow DROP of removed columns/tables',
'sql.seed.rows': 'Rows per table',
'sql.seed.seed': 'Seed (same seed = same data)',
'sql.seed.batch': 'Rows per INSERT',
'sql.opt.identIns': 'Include IDENTITY columns (SET IDENTITY_INSERT)',
'sql.opt.truncate': 'Clear tables first (DELETE)',
'sql.seed.hint': 'Values are inferred from the column type <b>and its name</b> (valid CPF/CNPJ, emails, names, cities, dates, prices...). Foreign keys only ever get values that exist in the parent table.',
'sql.generating': '-- generating...',
'sql.copy': 'Copy',
'sql.download': 'Download .sql',
'sql.close': 'Close',
'sql.meta': p => `${p.lines} lines · ${p.kb} KB · ${p.dialect}`,
'sql.copied': 'SQL copied to the clipboard.',
'sql.needTables': 'Create or import tables first.',
'sql.error': p => `-- ERROR: ${p.msg}`,
// ---------- export image ----------
'img.title': 'Export image',
'img.format': 'Format',
'img.svg': 'SVG (vector)',
'img.scale': 'Scale (PNG)',
'img.light': 'Light background (better for printing)',
'img.types': 'Show data types',
'img.go': 'Export',
'img.nothing': 'Nothing to export.',
'img.doneSvg': 'Diagram exported as SVG.',
'img.donePng': 'Diagram exported as PNG.',
'img.failPng': 'Could not generate the PNG.',
'img.footer': p => `${p.name} — ${p.tables} tables, ${p.rels} relationships`,
// ---------- layouts ----------
'lay.head': 'Arrange diagram',
'lay.spacing': p => `Spacing <b id="gapVal">${p.gap}</b> px`,
'lay.fitAfter': 'Fit to screen afterwards',
'lay.compare': 'Compare all layouts',
'lay.cmp.title': 'Layout comparison',
'lay.cmp.intro': 'Every layout was computed against the current model. <b>Crossings</b> are relationship lines that cut across each other; <b>lines over tables</b> are connections that pass on top of a box. The lower the numbers, the easier the diagram is to read.',
'lay.cmp.layout': 'Layout',
'lay.cmp.crossings': 'Crossings',
'lay.cmp.overlaps': 'Lines over tables',
'lay.cmp.apply': 'Apply',
'lay.cmp.best': 'best',
'lay.noTables': 'No tables to arrange.',
'lay.noCompare': 'No tables to compare.',
'lay.result': p =>
`${p.auto ? 'Best layout: ' : ''}${p.name} — ${p.crossings} ` +
`crossing${p.crossings === 1 ? '' : 's'}, ${p.overlaps} ` +
`line${p.overlaps === 1 ? '' : 's'} over tables (${p.ms} ms)`,
'lay.mode.auto.name': 'Automatic (best)',
'lay.mode.auto.desc': 'Tries several and keeps the one with fewest crossings',
'lay.mode.layered.name': 'Layered',
'lay.mode.layered.desc': 'Dependency hierarchy: parent tables on the left',
'lay.mode.radial.name': 'Star',
'lay.mode.radial.desc': 'Most connected table in the center, the rest in rings',
'lay.mode.fill.name': 'Fill the screen',
'lay.mode.fill.desc': 'Uses the whole visible rectangle, keeping neighbours together',
'lay.mode.force.name': 'Organic',
'lay.mode.force.desc': 'Force simulation: related tables cluster on their own',
'lay.mode.circle.name': 'Circle',
'lay.mode.circle.desc': 'Every table on a single ring',
'lay.mode.tree.name': 'Tree',
'lay.mode.tree.desc': 'Hierarchy from top to bottom',
'lay.mode.grid.name': 'Alphabetical grid',
'lay.mode.grid.desc': 'Alphabetical order, to find a table quickly',
// ---------- context menu ----------
'ctx.rename': '✎ Rename',
'ctx.addField': '+ Add field',
'ctx.duplicate': '⧉ Duplicate table',
'ctx.center': '⌖ Center',
'ctx.toFront': '⇱ Send to front',
'ctx.delTable': '🗑 Delete table',
'ctx.editPanel': '✎ Edit in the panel',
'ctx.pk': '🔑 Primary key',
'ctx.notNull': 'Required (NOT NULL)',
'ctx.unique': '★ Unique',
'ctx.identity': 'Auto increment',
'ctx.fieldBelow': '+ Field below',
'ctx.delField': '🗑 Delete field',
'ctx.editRel': '✎ Edit relationship',
'ctx.swapRel': '⇄ Reverse direction',
'ctx.delRel': '🗑 Delete relationship',
'ctx.newTableHere': '+ New table here',
'ctx.relayout': '⌗ Rearrange (last layout)',
'ctx.pickLayout': '▤ Pick a layout...',
'ctx.fit': '⤢ Fit to screen',
'ctx.import': '⬇ Import database',
'ctx.sql': '⚙ Generate SQL',
// ---------- general messages ----------
'msg.imported': p => `Imported: ${p.tables} tables and ${p.rels} relationships.`,
'msg.noRelsFound': 'No relationships were found in the source database. In Access, relationships are only readable when they are defined under "Relationships".',
'msg.projectLoaded': p => `Project loaded: ${p.name}`,
'msg.invalidFile': p => `Invalid file: ${p.msg}`,
'msg.demoLoaded': 'Example database loaded.',
'msg.projectSaved': 'Project saved as .dbdiag.json',
'msg.restored': p => `Previous session restored (${p.when}).`,
'msg.envFail': p => `Could not read the server environment: ${p.msg}`,
'msg.badResponse': p => `Invalid response from the server: ${p.text}`,
'msg.relWarning': p => `Relationship created, but ${p.table}.${p.column} is neither a primary key nor unique — the database may reject the FK.`,
'msg.newTableName': 'NewTable',
'msg.newFieldName': 'Field',
'msg.pkDescription': 'Primary key',
'confirm.delTables': p => `Delete ${p.n} table(s)?`,
'confirm.delTable': p => `Delete table "${p.name}" and its relationships?`,
'confirm.delSelected': p => `Delete ${p.n} tables and their relationships?`
}
};
const STORAGE = 'dbdiagram.lang.v1';
const listeners = [];
let lang = 'pt-BR';
function detect() {
try {
const saved = localStorage.getItem(STORAGE);
if (saved && DICT[saved]) return saved;
} catch (e) { /* modo privado */ }
const nav = (navigator.language || 'pt-BR').toLowerCase();
return nav.startsWith('pt') ? 'pt-BR' : 'en';
}
function t(key, params) {
const entry = (DICT[lang] && DICT[lang][key]) !== undefined
? DICT[lang][key]
: (DICT['pt-BR'][key] !== undefined ? DICT['pt-BR'][key] : key);
if (typeof entry === 'function') return entry(params || {});
if (params) {
return String(entry).replace(/\{(\w+)\}/g, (m, k) =>
(params[k] === undefined ? m : params[k]));
}
return entry;
}
/** Aplica as traduções aos elementos marcados no HTML. */
function apply(root) {
const scope = root || document;
scope.querySelectorAll('[data-i18n]').forEach(el => {
el.textContent = t(el.dataset.i18n);
});
scope.querySelectorAll('[data-i18n-html]').forEach(el => {
el.innerHTML = t(el.dataset.i18nHtml);
});
scope.querySelectorAll('[data-i18n-title]').forEach(el => {
el.title = t(el.dataset.i18nTitle);
});
scope.querySelectorAll('[data-i18n-ph]').forEach(el => {
el.placeholder = t(el.dataset.i18nPh);
});
document.documentElement.lang = t('html.lang');
}
function set(next, opts) {
if (!DICT[next] || next === lang) return;
lang = next;
try { localStorage.setItem(STORAGE, lang); } catch (e) { /* ignore */ }
apply();
if (!(opts && opts.silent)) listeners.forEach(fn => fn(lang));
}
function toggle() {
set(lang === 'pt-BR' ? 'en' : 'pt-BR');
}
function init() {
lang = detect();
apply();
}
return {
LANGS, init, apply, set, toggle, t,
get: () => lang,
short: () => (LANGS.find(l => l.id === lang) || LANGS[0]).short,
other: () => (lang === 'pt-BR' ? 'EN' : 'PT'),
onChange: fn => listeners.push(fn)
};
})();