335 Tools::InternationalLanguageTranslationEditor open |
312 Tools::InternationalLanguageTranslationEditor open |
336 " |
313 " |
337 |
314 |
338 <resource: #canvas> |
315 <resource: #canvas> |
339 |
316 |
340 ^ |
317 ^ |
341 #(FullSpec |
318 #(FullSpec |
342 name: windowSpec |
319 name: windowSpec |
343 window: |
320 window: |
344 (WindowSpec |
321 (WindowSpec |
345 label: 'InternationalLanguageTranslationEditor' |
322 label: 'InternationalLanguageTranslationEditor' |
346 name: 'InternationalLanguageTranslationEditor' |
323 name: 'InternationalLanguageTranslationEditor' |
347 min: (Point 10 10) |
324 min: (Point 10 10) |
348 bounds: (Rectangle 0 0 774 610) |
325 bounds: (Rectangle 0 0 774 610) |
349 menu: mainMenu |
326 menu: mainMenu |
350 ) |
327 ) |
351 component: |
328 component: |
352 (SpecCollection |
329 (SpecCollection |
353 collection: ( |
330 collection: ( |
354 (MenuPanelSpec |
331 (MenuPanelSpec |
355 name: 'ToolBar' |
332 name: 'ToolBar' |
356 layout: (LayoutFrame 0 0 0 0 0 1 30 0) |
333 layout: (LayoutFrame 0 0 0 0 0 1 30 0) |
357 menu: menuToolBar |
334 menu: menuToolBar |
358 textDefault: true |
335 textDefault: true |
359 ) |
336 ) |
360 (VariableVerticalPanelSpec |
337 (VariableVerticalPanelSpec |
361 name: 'TranslationsVariableVerticalPanel' |
338 name: 'TranslationsVariableVerticalPanel' |
362 layout: (LayoutFrame 0 0 30 0 0 1 -32 1) |
339 layout: (LayoutFrame 0 0 30 0 0 1 -32 1) |
363 component: |
340 component: |
364 (SpecCollection |
341 (SpecCollection |
365 collection: ( |
342 collection: ( |
366 (DataSetSpec |
343 (DataSetSpec |
367 name: 'KeyStringAndLanguageSelectionTable' |
344 name: 'KeyStringAndLanguageSelectionTable' |
368 model: selectedKeyRow |
345 model: selectedKeyRow |
369 menu: keyStringAndLanguageSelectionTableMenu |
346 menu: keyStringAndLanguageSelectionTableMenu |
370 hasHorizontalScrollBar: true |
347 hasHorizontalScrollBar: true |
371 hasVerticalScrollBar: true |
348 hasVerticalScrollBar: true |
372 dataList: keyStringAndLanguageSelectionTable |
349 dataList: keyStringAndLanguageSelectionTable |
373 columnHolder: keyStringAndLanguageSelectionTableColumnDescriptionHolder |
350 columnHolder: keyStringAndLanguageSelectionTableColumnDescriptionHolder |
374 beDependentOfRows: true |
351 beDependentOfRows: true |
375 columnAdaptor: yourself |
352 columnAdaptor: yourself |
376 postBuildCallback: postBuildDataSet: |
353 postBuildCallback: postBuildDataSet: |
377 ) |
354 ) |
378 (VariableVerticalPanelSpec |
355 (VariableVerticalPanelSpec |
379 name: 'VariableVerticalPanel1' |
356 name: 'VariableVerticalPanel1' |
380 component: |
357 component: |
381 (SpecCollection |
358 (SpecCollection |
382 collection: ( |
359 collection: ( |
383 (ViewSpec |
360 (ViewSpec |
384 name: 'Box1' |
361 name: 'Box1' |
385 component: |
362 component: |
386 (SpecCollection |
363 (SpecCollection |
387 collection: ( |
364 collection: ( |
388 (LabelSpec |
365 (LabelSpec |
389 label: 'Original String (Key):' |
366 label: 'Original String (Key):' |
390 name: 'Label2' |
367 name: 'Label2' |
391 layout: (LayoutFrame 0 0 -2 0 0 1 28 0) |
368 layout: (LayoutFrame 0 0 -2 0 0 1 28 0) |
392 translateLabel: true |
369 translateLabel: true |
393 adjust: left |
370 adjust: left |
394 ) |
371 ) |
395 (TextEditorSpec |
372 (TextEditorSpec |
396 name: 'OriginalText' |
373 name: 'OriginalText' |
397 layout: (LayoutFrame 0 0 27 0 0 1 -2 1) |
374 layout: (LayoutFrame 0 0 27 0 0 1 -2 1) |
398 model: originalTextHolder |
375 model: originalTextHolder |
399 hasHorizontalScrollBar: true |
376 hasHorizontalScrollBar: true |
400 hasVerticalScrollBar: true |
377 hasVerticalScrollBar: true |
401 modifiedChannel: originalTextModifiedHolder |
378 modifiedChannel: originalTextModifiedHolder |
402 acceptCallBack: languageTextAccepted |
379 acceptCallBack: languageTextAccepted |
403 hasKeyboardFocusInitially: false |
380 hasKeyboardFocusInitially: false |
404 ) |
381 ) |
405 ) |
382 ) |
406 |
383 |
407 ) |
384 ) |
408 ) |
385 ) |
409 (ViewSpec |
386 (ViewSpec |
410 name: 'Box3' |
387 name: 'Box3' |
411 component: |
388 component: |
412 (SpecCollection |
389 (SpecCollection |
413 collection: ( |
390 collection: ( |
414 (LabelSpec |
391 (LabelSpec |
415 label: 'Select Another Language as example:' |
392 label: 'Select Another Language as example:' |
416 name: 'Label3' |
393 name: 'Label3' |
417 layout: (LayoutFrame 0 0 -6 0 0 1 24 0) |
394 layout: (LayoutFrame 0 0 -6 0 0 1 24 0) |
418 translateLabel: true |
395 translateLabel: true |
419 adjust: left |
396 adjust: left |
420 ) |
397 ) |
421 (ComboBoxSpec |
398 (ComboBoxSpec |
422 name: 'ComboBox1' |
399 name: 'ComboBox1' |
423 layout: (LayoutFrame 281 0 -2 0 406 0 18 0) |
400 layout: (LayoutFrame 281 0 -2 0 406 0 18 0) |
424 model: exampleLanguageSelectionHolder |
401 model: exampleLanguageSelectionHolder |
425 immediateAccept: false |
402 immediateAccept: false |
426 acceptOnLeave: true |
403 acceptOnLeave: true |
427 acceptOnLostFocus: true |
404 acceptOnLostFocus: true |
428 acceptOnPointerLeave: false |
405 acceptOnPointerLeave: false |
429 comboList: shownLanguages |
406 comboList: shownLanguages |
430 useIndex: false |
407 useIndex: false |
431 ) |
408 ) |
432 (TextEditorSpec |
409 (TextEditorSpec |
433 name: 'ExampleLanguageText' |
410 name: 'ExampleLanguageText' |
434 layout: (LayoutFrame 0 0 30 0 0 1 0 1) |
411 layout: (LayoutFrame 0 0 30 0 0 1 0 1) |
435 model: exampleLanguageTextHolder |
412 model: exampleLanguageTextHolder |
436 hasHorizontalScrollBar: true |
413 hasHorizontalScrollBar: true |
437 hasVerticalScrollBar: true |
414 hasVerticalScrollBar: true |
438 isReadOnly: true |
415 isReadOnly: true |
439 hasKeyboardFocusInitially: false |
416 hasKeyboardFocusInitially: false |
440 ) |
417 ) |
441 ) |
418 ) |
442 |
419 |
443 ) |
420 ) |
444 ) |
421 ) |
445 (ViewSpec |
422 (ViewSpec |
446 name: 'Box2' |
423 name: 'Box2' |
447 component: |
424 component: |
448 (SpecCollection |
425 (SpecCollection |
449 collection: ( |
426 collection: ( |
450 (LabelSpec |
427 (LabelSpec |
451 label: 'Translated String:' |
428 label: 'Translated String:' |
452 name: 'Label1' |
429 name: 'Label1' |
453 layout: (LayoutFrame 0 0 0 0 0 1 30 0) |
430 layout: (LayoutFrame 0 0 0 0 0 1 30 0) |
454 translateLabel: true |
431 translateLabel: true |
455 adjust: left |
432 adjust: left |
456 ) |
433 ) |
457 (TextEditorSpec |
434 (TextEditorSpec |
458 name: 'LanguageText' |
435 name: 'LanguageText' |
459 layout: (LayoutFrame 0 0 30 0 0 1 0 1) |
436 layout: (LayoutFrame 0 0 30 0 0 1 0 1) |
460 model: languageTextHolder |
437 model: languageTextHolder |
461 hasHorizontalScrollBar: true |
438 hasHorizontalScrollBar: true |
462 hasVerticalScrollBar: true |
439 hasVerticalScrollBar: true |
463 acceptChannel: languageTextAcceptHolder |
440 acceptChannel: languageTextAcceptHolder |
464 modifiedChannel: languageTextModifiedHolder |
441 modifiedChannel: languageTextModifiedHolder |
465 acceptCallBack: languageTextAccepted |
442 acceptCallBack: languageTextAccepted |
466 hasKeyboardFocusInitially: false |
443 hasKeyboardFocusInitially: false |
467 postBuildCallback: languageEditorBuilt: |
444 postBuildCallback: languageEditorBuilt: |
468 ) |
445 ) |
469 (ActionButtonSpec |
446 (ActionButtonSpec |
470 label: 'Paste Previous' |
447 label: 'Paste Previous' |
471 name: 'pastePreviousTranslation' |
448 name: 'pastePreviousTranslation' |
472 layout: (LayoutOrigin 0 0.83085250338295003 0 0.034482758620689995) |
449 layout: (LayoutOrigin 0 0.83085250338295003 0 0.034482758620689995) |
473 translateLabel: true |
450 translateLabel: true |
474 model: pastePreviousTranslationInLanguageText |
451 model: pastePreviousTranslationInLanguageText |
475 enableChannel: pastePreviousTranslationEnableHolder |
452 enableChannel: pastePreviousTranslationEnableHolder |
476 disabledLogo: 'Paste Previous' |
453 disabledLogo: 'Paste Previous' |
477 ) |
454 ) |
478 (ActionButtonSpec |
455 (ActionButtonSpec |
479 label: 'Paste Original' |
456 label: 'Paste Original' |
480 name: 'Button1' |
457 name: 'Button1' |
481 layout: (LayoutOrigin -95 0.83085250338295003 0 0.034482758620689995) |
458 layout: (LayoutOrigin -95 0.83085250338295003 0 0.034482758620689995) |
482 translateLabel: true |
459 translateLabel: true |
483 model: pasteOriginalInLanguageText |
460 model: pasteOriginalInLanguageText |
484 enableChannel: pasteOriginalEnableHolder |
461 enableChannel: pasteOriginalEnableHolder |
485 disabledLogo: 'Paste Original' |
462 disabledLogo: 'Paste Original' |
486 ) |
463 ) |
487 ) |
464 ) |
488 |
465 |
489 ) |
466 ) |
490 ) |
467 ) |
491 ) |
468 ) |
492 |
469 |
493 ) |
470 ) |
494 handles: (Any 0.3333333333333301 0.66666666666667018 1.0) |
471 handles: (Any 0.3333333333333301 0.66666666666667018 1.0) |
495 ) |
472 ) |
496 ) |
473 ) |
497 |
474 |
498 ) |
475 ) |
499 handles: (Any 0.5 1.0) |
476 handles: (Any 0.5 1.0) |
500 postBuildCallback: postBuildTranslationsPanel: |
477 postBuildCallback: postBuildTranslationsPanel: |
501 ) |
478 ) |
502 (ViewSpec |
479 (ViewSpec |
503 name: 'SearchBox' |
480 name: 'SearchBox' |
504 layout: (LayoutFrame 0 0 -32 1 0 1 0 1) |
481 layout: (LayoutFrame 0 0 -32 1 0 1 0 1) |
505 level: -1 |
482 level: -1 |
506 visibilityChannel: searchBoxVisible |
483 visibilityChannel: searchBoxVisible |
507 component: |
484 component: |
508 (SpecCollection |
485 (SpecCollection |
509 collection: ( |
486 collection: ( |
510 (ActionButtonSpec |
487 (ActionButtonSpec |
511 label: 'closeSearchBarIcon' |
488 label: 'closeSearchBarIcon' |
512 name: 'closeSearchBarButton' |
489 name: 'closeSearchBarButton' |
513 layout: (LayoutFrame 4 0 5 0 25 0 26 0) |
490 layout: (LayoutFrame 4 0 5 0 25 0 26 0) |
514 hasCharacterOrientedLabel: false |
491 hasCharacterOrientedLabel: false |
515 translateLabel: true |
492 translateLabel: true |
516 model: closeSearchBar |
493 model: closeSearchBar |
517 ) |
494 ) |
518 (LabelSpec |
495 (LabelSpec |
519 label: 'Search:' |
496 label: 'Search:' |
520 name: 'SearchLabel' |
497 name: 'SearchLabel' |
521 layout: (LayoutFrame 30 0 5 0 100 0 27 0) |
498 layout: (LayoutFrame 30 0 5 0 100 0 27 0) |
522 translateLabel: true |
499 translateLabel: true |
523 adjust: right |
500 adjust: right |
524 ) |
501 ) |
525 (InputFieldSpec |
502 (InputFieldSpec |
526 name: 'SearchEntryField' |
503 name: 'SearchEntryField' |
527 layout: (LayoutFrame 100 0 5 0 257 0 27 0) |
504 layout: (LayoutFrame 100 0 5 0 257 0 27 0) |
528 model: searchTextHolder |
505 model: searchTextHolder |
529 immediateAccept: true |
506 immediateAccept: true |
530 acceptOnReturn: true |
507 acceptOnReturn: true |
531 acceptOnTab: true |
508 acceptOnTab: true |
532 acceptOnLostFocus: true |
509 acceptOnLostFocus: true |
533 modifiedChannel: searchTextModifiedHolder |
510 modifiedChannel: searchTextModifiedHolder |
534 acceptOnPointerLeave: false |
511 acceptOnPointerLeave: false |
535 postBuildCallback: postBuildSearchTextView: |
512 postBuildCallback: postBuildSearchTextView: |
536 ) |
513 ) |
537 (ActionButtonSpec |
514 (ActionButtonSpec |
538 label: 'searchNextIcon' |
515 label: 'searchNextIcon' |
539 name: 'SearchNextButton' |
516 name: 'SearchNextButton' |
540 layout: (LayoutFrame 264 0 5 0 285 0 26 0) |
517 layout: (LayoutFrame 264 0 5 0 285 0 26 0) |
541 hasCharacterOrientedLabel: false |
518 hasCharacterOrientedLabel: false |
542 translateLabel: true |
519 translateLabel: true |
543 model: searchNextText |
520 model: searchNextText |
544 ) |
521 ) |
545 (ActionButtonSpec |
522 (ActionButtonSpec |
546 label: 'searchPreviousIcon' |
523 label: 'searchPreviousIcon' |
547 name: 'searchPreviousButton' |
524 name: 'searchPreviousButton' |
548 layout: (LayoutFrame 292 0 5 0 313 0 26 0) |
525 layout: (LayoutFrame 292 0 5 0 313 0 26 0) |
549 hasCharacterOrientedLabel: false |
526 hasCharacterOrientedLabel: false |
550 translateLabel: true |
527 translateLabel: true |
551 model: searchPreviousText |
528 model: searchPreviousText |
552 ) |
529 ) |
553 (CheckBoxSpec |
530 (CheckBoxSpec |
554 label: 'Ignore case' |
531 label: 'Ignore case' |
555 name: 'IgnoreCaseCheckBox' |
532 name: 'IgnoreCaseCheckBox' |
556 layout: (LayoutFrame 322 0 5 0 518 0 27 0) |
533 layout: (LayoutFrame 322 0 5 0 518 0 27 0) |
557 model: ignoreCaseHolder |
534 model: ignoreCaseHolder |
558 translateLabel: true |
535 translateLabel: true |
559 ) |
536 ) |
560 (LabelSpec |
537 (LabelSpec |
561 label: 'SearchBarImageInfoLabel' |
538 label: 'SearchBarImageInfoLabel' |
562 name: 'SearchBarImageInfoLabel' |
539 name: 'SearchBarImageInfoLabel' |
563 layout: (LayoutFrame 524 0 5 0 548 0 27 0) |
540 layout: (LayoutFrame 524 0 5 0 548 0 27 0) |
564 hasCharacterOrientedLabel: false |
541 hasCharacterOrientedLabel: false |
565 translateLabel: true |
542 translateLabel: true |
566 labelChannel: searchBarImageInfoLabelHolder |
543 labelChannel: searchBarImageInfoLabelHolder |
567 ) |
544 ) |
568 (LabelSpec |
545 (LabelSpec |
569 label: 'SearchBarInfoLabel' |
546 label: 'SearchBarInfoLabel' |
570 name: 'SearchBarInfoLabel' |
547 name: 'SearchBarInfoLabel' |
571 layout: (LayoutFrame 551 0 5 0 829 0 27 0) |
548 layout: (LayoutFrame 551 0 5 0 829 0 27 0) |
572 translateLabel: true |
549 translateLabel: true |
573 labelChannel: searchBarInfoLabelHolder |
550 labelChannel: searchBarInfoLabelHolder |
574 adjust: left |
551 adjust: left |
575 ) |
552 ) |
576 ) |
553 ) |
577 |
554 |
578 ) |
555 ) |
579 postBuildCallback: postBuildSearchBoxView: |
556 postBuildCallback: postBuildSearchBoxView: |
580 ) |
557 ) |
581 ) |
558 ) |
582 |
559 |
583 ) |
560 ) |
584 ) |
561 ) |
585 ! ! |
562 ! ! |
586 |
563 |
587 !InternationalLanguageTranslationEditor class methodsFor:'menu specs'! |
564 !InternationalLanguageTranslationEditor class methodsFor:'menu specs'! |
652 (Menu new fromLiteralArrayEncoding:(Tools::InternationalLanguageTranslationEditor mainMenu)) startUp |
629 (Menu new fromLiteralArrayEncoding:(Tools::InternationalLanguageTranslationEditor mainMenu)) startUp |
653 " |
630 " |
654 |
631 |
655 <resource: #menu> |
632 <resource: #menu> |
656 |
633 |
657 ^ |
634 ^ |
658 #(Menu |
635 #(Menu |
659 ( |
636 ( |
660 (MenuItem |
637 (MenuItem |
661 label: 'File' |
638 label: 'File' |
662 submenu: |
639 submenu: |
663 (Menu |
640 (Menu |
664 ( |
641 ( |
665 (MenuItem |
642 (MenuItem |
666 label: 'New' |
643 label: 'New' |
667 itemValue: menuNew |
644 itemValue: menuNew |
668 ) |
645 ) |
669 (MenuItem |
646 (MenuItem |
670 label: '-' |
647 label: '-' |
671 ) |
648 ) |
672 (MenuItem |
649 (MenuItem |
673 label: 'Open Resources for Package or Project...' |
650 label: 'Open Resources for Package or Project...' |
674 itemValue: menuOpenByPackage |
651 itemValue: menuOpenByPackage |
675 ) |
652 ) |
676 (MenuItem |
653 (MenuItem |
677 label: 'Open Resource File...' |
654 label: 'Open Resource File...' |
678 itemValue: menuOpen |
655 itemValue: menuOpen |
679 ) |
656 ) |
680 (MenuItem |
657 (MenuItem |
681 label: '-' |
658 label: '-' |
682 ) |
659 ) |
683 (MenuItem |
660 (MenuItem |
684 label: 'Save All Resource Files' |
661 label: 'Save All Resource Files' |
685 itemValue: menuSaveAll |
662 itemValue: menuSaveAll |
686 ) |
663 ) |
687 (MenuItem |
664 (MenuItem |
688 label: 'Save Resource File' |
665 label: 'Save Resource File' |
689 itemValue: menuSave |
666 itemValue: menuSave |
690 ) |
667 ) |
691 (MenuItem |
668 (MenuItem |
692 label: 'Save Resource File As...' |
669 label: 'Save Resource File As...' |
693 itemValue: menuSaveAs |
670 itemValue: menuSaveAs |
694 ) |
671 ) |
695 (MenuItem |
672 (MenuItem |
696 label: '-' |
673 label: '-' |
697 ) |
674 ) |
698 (MenuItem |
675 (MenuItem |
699 label: 'Import existing translations from file...' |
676 label: 'Import existing translations from file...' |
700 itemValue: importExistingTranslationsFromFile |
677 itemValue: importExistingTranslationsFromFile |
701 ) |
678 ) |
702 (MenuItem |
679 (MenuItem |
703 label: '-' |
680 label: '-' |
704 ) |
681 ) |
705 (MenuItem |
682 (MenuItem |
706 label: 'Set Current NameSpace' |
683 label: 'Set Current NameSpace' |
707 itemValue: changeLastNameSpace |
684 itemValue: changeLastNameSpace |
708 ) |
685 ) |
709 (MenuItem |
686 (MenuItem |
710 label: 'Set Current Package' |
687 label: 'Set Current Package' |
711 itemValue: changeLastPackage |
688 itemValue: changeLastPackage |
712 isVisible: false |
689 isVisible: false |
713 ) |
690 ) |
714 (MenuItem |
691 (MenuItem |
715 label: '-' |
692 label: '-' |
716 ) |
693 ) |
717 (MenuItem |
694 (MenuItem |
718 label: 'Exit' |
695 label: 'Exit' |
719 itemValue: closeRequest |
696 itemValue: closeRequest |
720 ) |
697 ) |
721 ) |
698 ) |
722 nil |
699 nil |
723 nil |
700 nil |
724 ) |
701 ) |
725 ) |
702 ) |
726 (MenuItem |
703 (MenuItem |
727 label: 'View' |
704 label: 'View' |
728 submenu: |
705 submenu: |
729 (Menu |
706 (Menu |
730 ( |
707 ( |
731 (MenuItem |
708 (MenuItem |
732 label: 'Show Missing Translations Only' |
709 label: 'Show Missing Translations Only' |
733 indication: showMissingTranslationsOnly |
710 indication: showMissingTranslationsOnly |
734 ) |
711 ) |
735 (MenuItem |
712 (MenuItem |
736 label: 'Show Search Box' |
713 label: 'Show Search Box' |
737 indication: searchBoxVisible |
714 indication: searchBoxVisible |
738 ) |
715 ) |
739 (MenuItem |
716 (MenuItem |
740 label: '-' |
717 label: '-' |
741 ) |
718 ) |
742 (MenuItem |
719 (MenuItem |
743 label: 'Shown Languages' |
720 label: 'Shown Languages' |
744 submenuChannel: shownLanguagesMenu |
721 submenuChannel: shownLanguagesMenu |
745 ) |
722 ) |
746 ) |
723 ) |
747 nil |
724 nil |
748 nil |
725 nil |
749 ) |
726 ) |
750 ) |
727 ) |
751 (MenuItem |
728 (MenuItem |
752 label: 'Languages' |
729 label: 'Languages' |
753 submenu: |
730 submenu: |
754 (Menu |
731 (Menu |
755 ( |
732 ( |
756 (MenuItem |
733 (MenuItem |
757 label: 'Add Language...' |
734 label: 'Add Language...' |
758 itemValue: addLanguage |
735 itemValue: addLanguage |
759 ) |
736 ) |
760 (MenuItem |
737 (MenuItem |
761 label: 'Remove Language...' |
738 label: 'Remove Language...' |
762 itemValue: removeLanguage |
739 itemValue: removeLanguage |
763 ) |
740 ) |
764 ) |
741 ) |
765 nil |
742 nil |
766 nil |
743 nil |
767 ) |
744 ) |
768 ) |
745 ) |
769 (MenuItem |
746 (MenuItem |
770 label: 'Translations' |
747 label: 'Translations' |
771 submenuChannel: translationsMenuSpec |
748 submenuChannel: translationsMenuSpec |
772 ) |
749 ) |
773 (MenuItem |
750 (MenuItem |
774 label: 'Preferences' |
751 label: 'Preferences' |
775 submenu: |
752 submenu: |
776 (Menu |
753 (Menu |
777 ( |
754 ( |
778 (MenuItem |
755 (MenuItem |
779 label: 'Auto Accept Changes' |
756 label: 'Auto Accept Changes' |
780 indication: autoAcceptHolder |
757 indication: autoAcceptHolder |
781 ) |
758 ) |
782 (MenuItem |
759 (MenuItem |
783 label: 'Search For Similar Translations' |
760 label: 'Search For Similar Translations' |
784 indication: searchForSimilarTranslationEnableHolder |
761 indication: searchForSimilarTranslationEnableHolder |
785 ) |
762 ) |
786 (MenuItem |
763 (MenuItem |
787 label: 'Always Write UTF8' |
764 label: 'Always Write UTF8' |
788 indication: alwaysWriteUTF8Holder |
765 indication: alwaysWriteUTF8Holder |
789 ) |
766 ) |
790 ) |
767 ) |
791 nil |
768 nil |
792 nil |
769 nil |
793 ) |
770 ) |
794 ) |
771 ) |
795 (MenuItem |
772 (MenuItem |
796 label: 'Help' |
773 label: 'Help' |
797 startGroup: right |
774 startGroup: right |
798 submenu: |
775 submenu: |
799 (Menu |
776 (Menu |
800 ( |
777 ( |
801 (MenuItem |
778 (MenuItem |
802 label: 'Documentation' |
779 label: 'Documentation' |
803 itemValue: openDocumentation |
780 itemValue: openDocumentation |
804 ) |
781 ) |
805 (MenuItem |
782 (MenuItem |
806 label: '-' |
783 label: '-' |
807 ) |
784 ) |
808 (MenuItem |
785 (MenuItem |
809 label: 'About this Application...' |
786 label: 'About this Application...' |
810 itemValue: openAboutThisApplication |
787 itemValue: openAboutThisApplication |
811 ) |
788 ) |
812 ) |
789 ) |
813 nil |
790 nil |
814 nil |
791 nil |
815 ) |
792 ) |
816 ) |
793 ) |
817 ) |
794 ) |
818 nil |
795 nil |
819 nil |
796 nil |
820 ) |
797 ) |
821 ! |
798 ! |
822 |
799 |
823 menuItemsEditLanguage |
800 menuItemsEditLanguage |
824 "This resource specification was automatically generated |
801 "This resource specification was automatically generated |
1761 extractTranslationsFromProject |
1738 extractTranslationsFromProject |
1762 |projectID newTranslations initialAnswer suggestions| |
1739 |projectID newTranslations initialAnswer suggestions| |
1763 |
1740 |
1764 initialAnswer := lastExtractedProject ? LastExtractedProject. |
1741 initialAnswer := lastExtractedProject ? LastExtractedProject. |
1765 suggestions := initialAnswer isNil ifTrue:[ |
1742 suggestions := initialAnswer isNil ifTrue:[ |
1766 OrderedCollection new |
1743 OrderedCollection new |
1767 ] ifFalse:[ |
1744 ] ifFalse:[ |
1768 OrderedCollection with:initialAnswer |
1745 OrderedCollection with:initialAnswer |
1769 ]. |
1746 ]. |
1770 projectID := Dialog requestProject:(resources string:'Package to extract translations from:') initialAnswer:initialAnswer suggestions:suggestions. |
1747 projectID := Dialog requestProject:(resources string:'Package to extract translations from:') initialAnswer:initialAnswer suggestions:suggestions. |
1771 projectID notNil ifTrue:[ |
1748 projectID notNil ifTrue:[ |
1772 projectID := projectID withoutSeparators asSymbol. |
1749 projectID := projectID withoutSeparators asSymbol. |
1773 ]. |
1750 ]. |
1774 projectID isEmptyOrNil ifTrue:[^ self ]. |
1751 projectID isEmptyOrNil ifTrue:[^ self ]. |
1775 |
1752 |
1776 lastExtractedProject := LastExtractedProject := projectID. |
1753 lastExtractedProject := LastExtractedProject := projectID. |
1777 |
1754 |
1778 newTranslations := Set new. |
1755 newTranslations := Set new. |
1779 self withWaitCursorDo:[ |
1756 self withWaitCursorDo:[ |
1780 Smalltalk allClassesDo:[:eachClass | |
1757 Smalltalk allClassesDo:[:eachClass | |
1781 eachClass theNonMetaclass instAndClassMethodsDo:[:eachMethod | |
1758 eachClass theNonMetaclass instAndClassMethodsDo:[:eachMethod | |
1782 eachMethod package == projectID ifTrue:[ |
1759 eachMethod package == projectID ifTrue:[ |
1783 newTranslations addAll:( self extractTranslationsFromMethod:eachMethod ). |
1760 newTranslations addAll:( self extractTranslationsFromMethod:eachMethod ). |
1784 ] |
1761 ] |
1785 ]. |
1762 ]. |
1786 ]. |
1763 ]. |
1787 |
1764 |
1788 self addAllTranslations:newTranslations. |
1765 self addAllTranslations:newTranslations. |
1789 ]. |
1766 ]. |
1790 |
1767 |
1791 "Modified: / 19-02-2015 / 11:44:24 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
1768 "Modified: / 19-02-2015 / 11:44:24 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
1792 "Modified: / 16-08-2017 / 12:29:21 / mawalch" |
1769 "Modified: / 16-08-2017 / 12:29:21 / mawalch" |
1793 ! |
1770 ! |
1794 |
1771 |
1795 generateMissingTranslations: keys for: languages using: translator |
1772 generateMissingTranslations: keys for: languages using: translator |
1796 keys do:[:string | |
1773 keys do:[:string | |
1797 languages do:[:lang | |
1774 languages do:[:lang | |
1798 | translation | |
1775 | translation | |
1799 |
1776 |
1800 translation := keyStringsToLanguageMappings at:string language:lang. |
1777 translation := keyStringsToLanguageMappings at:string language:lang. |
1801 translation isNil ifTrue:[ |
1778 translation isNil ifTrue:[ |
1802 translation := translator value: lang value: string. |
1779 translation := translator value: lang value: string. |
1803 translation notNil ifTrue:[ |
1780 translation notNil ifTrue:[ |
1804 keyStringsToLanguageMappings at: string language: lang put: translation. |
1781 keyStringsToLanguageMappings at: string language: lang put: translation. |
1805 ]. |
1782 ]. |
1806 ]. |
1783 ]. |
1807 ]. |
1784 ]. |
1808 ]. |
1785 ]. |
1809 |
1786 |
1810 "Created: / 19-02-2015 / 12:31:25 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
1787 "Created: / 19-02-2015 / 12:31:25 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
1811 ! |
1788 ! |
1812 |
1789 |
1813 generateMissingTranslationsFor: languages |
1790 generateMissingTranslationsFor: languages |
1814 self |
1791 self |
1815 generateMissingTranslations: keyStringsToLanguageMappings keys |
1792 generateMissingTranslations: keyStringsToLanguageMappings keys |
1816 for: languages |
1793 for: languages |
1817 using: [ :lang :string | '**%1** %2' bindWith: lang asUppercase with: string ] |
1794 using: [ :lang :string | '**%1** %2' bindWith: lang asUppercase with: string ] |
1818 |
1795 |
1819 "Created: / 19-02-2015 / 12:39:46 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
1796 "Created: / 19-02-2015 / 12:39:46 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
1820 ! |
1797 ! |
1821 |
1798 |
1822 generateMissingTranslationsForAll |
1799 generateMissingTranslationsForAll |
2018 |
1995 |
2019 runApplicationAndCollectTranslations |
1996 runApplicationAndCollectTranslations |
2020 |applicationClass newTranslations pseudoPack app startSelector| |
1997 |applicationClass newTranslations pseudoPack app startSelector| |
2021 |
1998 |
2022 monitoredApplication notNil ifTrue:[ |
1999 monitoredApplication notNil ifTrue:[ |
2023 monitoredApplication terminate. |
2000 monitoredApplication terminate. |
2024 [monitoredApplication notNil] whileTrue:[ |
2001 [monitoredApplication notNil] whileTrue:[ |
2025 Delay waitForSeconds:0.1 |
2002 Delay waitForSeconds:0.1 |
2026 ]. |
2003 ]. |
2027 ]. |
2004 ]. |
2028 |
2005 |
2029 applicationClass := Dialog |
2006 applicationClass := Dialog |
2030 requestClass:'Application class to start and collect translations from:' |
2007 requestClass:'Application class to start and collect translations from:' |
2031 okLabel:'OK' |
2008 okLabel:'OK' |
2032 initialAnswer:(lastExtractedApplicationClass ? LastExtractedApplicationClass ). |
2009 initialAnswer:(lastExtractedApplicationClass ? LastExtractedApplicationClass ). |
2033 applicationClass isNil ifTrue:[^ self ]. |
2010 applicationClass isNil ifTrue:[^ self ]. |
2034 applicationClass isNameSpace ifTrue:[ |
2011 applicationClass isNameSpace ifTrue:[ |
2035 Dialog warn:'Entered class is a NameSpace'. |
2012 Dialog warn:'Entered class is a NameSpace'. |
2036 ^ self. |
2013 ^ self. |
2037 ]. |
2014 ]. |
2038 |
2015 |
2039 applicationClass isVisualStartable ifTrue:[ |
2016 applicationClass isVisualStartable ifTrue:[ |
2040 startSelector := #open |
2017 startSelector := #open |
2041 ] ifFalse:[ |
2018 ] ifFalse:[ |
2042 startSelector := Dialog |
2019 startSelector := Dialog |
2043 request:'Entered class seems to be no application class. Ok to start using selector:' |
2020 request:'Entered class seems to be no application class. Ok to start using selector:' |
2044 initialAnswer:((applicationClass respondsTo:#'start') |
2021 initialAnswer:((applicationClass respondsTo:#'start') |
2045 ifTrue:#'start' |
2022 ifTrue:#'start' |
2046 ifFalse:#'new') |
2023 ifFalse:#'new') |
2047 okLabel:'START' |
2024 okLabel:'START' |
2048 title:'Start Application'. |
2025 title:'Start Application'. |
2049 startSelector isNil ifTrue:[ |
2026 startSelector isNil ifTrue:[ |
2050 ^ self |
2027 ^ self |
2051 ]. |
2028 ]. |
2052 startSelector := startSelector asSymbol. |
2029 startSelector := startSelector asSymbol. |
2053 ]. |
2030 ]. |
2054 |
2031 |
2055 lastExtractedApplicationClass := LastExtractedApplicationClass := applicationClass. |
2032 lastExtractedApplicationClass := LastExtractedApplicationClass := applicationClass. |
2056 |
2033 |
2057 newTranslations := Set new. |
2034 newTranslations := Set new. |
2112 selectedKey := self selectedKey. |
2089 selectedKey := self selectedKey. |
2113 selectedKey isNil ifTrue:[^ Dialog information: 'No selected key']. |
2090 selectedKey isNil ifTrue:[^ Dialog information: 'No selected key']. |
2114 |
2091 |
2115 browser := NewSystemBrowser new "open". |
2092 browser := NewSystemBrowser new "open". |
2116 browser allButOpen. |
2093 browser allButOpen. |
2117 |
2094 |
2118 lastSearchPatterns := browser lastSearchPatterns. |
2095 lastSearchPatterns := browser lastSearchPatterns. |
2119 (lastSearchPatterns notNil and:[lastSearchPatterns first ~= selectedKey]) ifTrue:[ |
2096 (lastSearchPatterns notNil and:[lastSearchPatterns first ~= selectedKey]) ifTrue:[ |
2120 browser lastSearchPatterns addFirst: selectedKey |
2097 browser lastSearchPatterns addFirst: selectedKey |
2121 ]. |
2098 ]. |
2122 SearchDialog lastStringSearchArea: #currentPackage. |
2099 SearchDialog lastStringSearchArea: #currentPackage. |
2123 lastPackage isNil ifTrue:[ |
2100 lastPackage isNil ifTrue:[ |
2124 self changeLastPackage. |
2101 self changeLastPackage. |
2125 ]. |
2102 ]. |
2126 lastPackage notNil ifTrue:[ |
2103 lastPackage notNil ifTrue:[ |
2127 "/ browser navigationState selectedClasses value: lastNameSpace allClasses. |
2104 "/ browser navigationState selectedClasses value: lastNameSpace allClasses. |
2128 browser navigationState packageFilter value: (OrderedCollection with:lastPackage). |
2105 browser navigationState packageFilter value: (OrderedCollection with:lastPackage). |
2129 browser navigationState selectedProjects value: (OrderedCollection with:lastPackage). |
2106 browser navigationState selectedProjects value: (OrderedCollection with:lastPackage). |
2130 ]. |
2107 ]. |
2131 self withWaitCursorDo:[ |
2108 self withWaitCursorDo:[ |
2132 browser |
2109 browser |
2133 askForMethodAndSpawnSearchTitle:'String to Search for in Sources:' |
2110 askForMethodAndSpawnSearchTitle:'String to Search for in Sources:' |
2134 browserLabel:'Methods containing "%1"' |
2111 browserLabel:'Methods containing "%1"' |
2135 searchWith:#( #'findString:in:ignoreCase:match:' #'findString:inMethods:ignoreCase:match:' ) |
2112 searchWith:#( #'findString:in:ignoreCase:match:' #'findString:inMethods:ignoreCase:match:' ) |
2136 searchWhat:#string |
2113 searchWhat:#string |
2137 searchArea:#currentPackage |
2114 searchArea:#currentPackage |
2138 withCaseIgnore:false |
2115 withCaseIgnore:false |
2139 withTextEntry:false |
2116 withTextEntry:false |
2140 withMatch:true |
2117 withMatch:true |
2141 withMethodList:false |
2118 withMethodList:false |
2142 setSearchPattern:[:brwsr :string :ignoreCase :doMatch| |
2119 setSearchPattern:[:brwsr :string :ignoreCase :doMatch| |
2143 brwsr autoSearchPattern:string ignoreCase:ignoreCase. |
2120 brwsr autoSearchPattern:string ignoreCase:ignoreCase. |
2144 ] |
2121 ] |
2145 initialText:selectedKey "/ does not work: ('''*',selectedKey,'*''') check match!! |
2122 initialText:selectedKey "/ does not work: ('''*',selectedKey,'*''') check match!! |
2146 ]. |
2123 ]. |
2147 ! ! |
2124 ! ! |
2148 |
2125 |
2149 !InternationalLanguageTranslationEditor methodsFor:'menus dynamic'! |
2126 !InternationalLanguageTranslationEditor methodsFor:'menus dynamic'! |
2150 |
2127 |
2215 |
2192 |
2216 !InternationalLanguageTranslationEditor methodsFor:'private-key extraction'! |
2193 !InternationalLanguageTranslationEditor methodsFor:'private-key extraction'! |
2217 |
2194 |
2218 addAllTranslations:newTranslations |
2195 addAllTranslations:newTranslations |
2219 "merge found xlations into the list of already present xlations" |
2196 "merge found xlations into the list of already present xlations" |
2220 |
2197 |
2221 |newTranslationKeys stringKeys nonStringKeys| |
2198 |newTranslationKeys stringKeys nonStringKeys| |
2222 |
2199 |
2223 newTranslationKeys := newTranslations select:[:k | k notEmptyOrNil and:[k isString not or:[k isBlank not]]]. |
2200 newTranslationKeys := newTranslations select:[:k | k notEmptyOrNil and:[k isString not or:[k isBlank not]]]. |
2224 newTranslationKeys := newTranslationKeys select:[:k | (keyStringsToLanguageMappings includesKey:k) not]. |
2201 newTranslationKeys := newTranslationKeys select:[:k | (keyStringsToLanguageMappings includesKey:k) not]. |
2225 "/ follow the common-xlations algrithm of ResourcePack |
2202 "/ follow the common-xlations algrithm of ResourcePack |
2226 "/ (which knows how to xlate strings with additional special chars.) |
2203 "/ (which knows how to xlate strings with additional special chars.) |
2227 newTranslationKeys := |
2204 newTranslationKeys := |
2228 newTranslationKeys collect:[:oldKey | |
2205 newTranslationKeys collect:[:oldKey | |
2229 |newKey methods| |
2206 |newKey methods| |
2230 |
2207 |
2231 (oldKey endsWith:' ...') ifTrue:[ |
2208 (oldKey endsWith:' ...') ifTrue:[ |
2232 newKey := oldKey copyButLast:4. |
2209 newKey := oldKey copyButLast:4. |
2233 ] ifFalse:[ (oldKey endsWith:'...') ifTrue:[ |
2210 ] ifFalse:[ (oldKey endsWith:'...') ifTrue:[ |
2234 newKey := oldKey copyButLast:3. |
2211 newKey := oldKey copyButLast:3. |
2235 ] ifFalse:[ ('\.:?=,!! ' includes:oldKey last) ifTrue:[ |
2212 ] ifFalse:[ ('\.:?=,!! ' includes:oldKey last) ifTrue:[ |
2236 newKey := oldKey copyButLast:1. |
2213 newKey := oldKey copyButLast:1. |
2237 ] ifFalse:[ ((oldKey first == $() and:[ oldKey last == $) ]) ifTrue:[ |
2214 ] ifFalse:[ ((oldKey first == $() and:[ oldKey last == $) ]) ifTrue:[ |
2238 newKey := oldKey copyFrom:2 to:oldKey size - 1 |
2215 newKey := oldKey copyFrom:2 to:oldKey size - 1 |
2239 ] ifFalse:[ ((oldKey first == $[) and:[ oldKey last == $] ]) ifTrue:[ |
2216 ] ifFalse:[ ((oldKey first == $[) and:[ oldKey last == $] ]) ifTrue:[ |
2240 newKey := oldKey copyFrom:2 to:oldKey size - 1 |
2217 newKey := oldKey copyFrom:2 to:oldKey size - 1 |
2241 ] ifFalse:[ |
2218 ] ifFalse:[ |
2242 newKey :=oldKey |
2219 newKey :=oldKey |
2243 ]]]]]. |
2220 ]]]]]. |
2244 "/ must attach oldKey-methods to newKey |
2221 "/ must attach oldKey-methods to newKey |
2245 methods := methodsUsingKey at:oldKey ifAbsent:nil. |
2222 methods := methodsUsingKey at:oldKey ifAbsent:nil. |
2246 methods notNil ifTrue:[ |
2223 methods notNil ifTrue:[ |
2247 (methodsUsingKey at:newKey ifAbsentPut:[Set new]) addAll:methods |
2224 (methodsUsingKey at:newKey ifAbsentPut:[Set new]) addAll:methods |
2248 ]. |
2225 ]. |
2249 newKey |
2226 newKey |
2250 ]. |
2227 ]. |
2251 |
2228 |
2252 newTranslationKeys := newTranslationKeys asSet. |
2229 newTranslationKeys := newTranslationKeys asSet. |
2253 newTranslationKeys := newTranslationKeys select:[:k | (keyStringsToLanguageMappings includesKey:k) not]. |
2230 newTranslationKeys := newTranslationKeys select:[:k | (keyStringsToLanguageMappings includesKey:k) not]. |
2254 |
2231 |
2255 newTranslationKeys notEmpty ifTrue:[ |
2232 newTranslationKeys notEmpty ifTrue:[ |
2256 stringKeys := newTranslationKeys select:[:k | k isString]. |
2233 stringKeys := newTranslationKeys select:[:k | k isString]. |
2257 nonStringKeys := newTranslationKeys select:[:k | k isString not]. |
2234 nonStringKeys := newTranslationKeys select:[:k | k isString not]. |
2258 |
2235 |
2259 stringKeys := stringKeys asSortedCollection. |
2236 stringKeys := stringKeys asSortedCollection. |
2260 keyStringsToLanguageMappings addKeys:stringKeys. |
2237 keyStringsToLanguageMappings addKeys:stringKeys. |
2261 keyStringsToLanguageMappings addKeys:nonStringKeys. |
2238 keyStringsToLanguageMappings addKeys:nonStringKeys. |
2262 modified := true. |
2239 modified := true. |
2263 ]. |
2240 ]. |
2264 ! |
2241 ! |
2265 |
2242 |
2266 extractTranslationsFromClass:aClass |
2243 extractTranslationsFromClass:aClass |
2267 |newTranslations| |
2244 |newTranslations| |
2268 |
2245 |
2269 newTranslations := Set new. |
2246 newTranslations := Set new. |
2270 |
2247 |
2271 self withWaitCursorDo:[ |
2248 self withWaitCursorDo:[ |
2272 "/ now, the hard part: |
2249 "/ now, the hard part: |
2273 "/ possible translations are in the specs, |
2250 "/ possible translations are in the specs, |
2274 "/ and all arguments to (resources string:) messages. |
2251 "/ and all arguments to (resources string:) messages. |
2275 aClass instAndClassMethodsDo:[:eachMethod | |
2252 aClass instAndClassMethodsDo:[:eachMethod | |
2276 newTranslations addAll:( self extractTranslationsFromMethod:eachMethod ). |
2253 newTranslations addAll:( self extractTranslationsFromMethod:eachMethod ). |
2277 ]. |
2254 ]. |
2278 ]. |
2255 ]. |
2279 |
2256 |
2280 newTranslations := |
2257 newTranslations := |
2281 newTranslations select:[:eachTranslation| |
2258 newTranslations select:[:eachTranslation| |
2282 (aClass resources at:eachTranslation ifAbsent:nil) isNil |
2259 (aClass resources at:eachTranslation ifAbsent:nil) isNil |
2283 ]. |
2260 ]. |
2284 ^ newTranslations |
2261 ^ newTranslations |
2285 ! |
2262 ! |
2286 |
2263 |
2287 extractTranslationsFromHelpSpecMethod:aMethod |
2264 extractTranslationsFromHelpSpecMethod:aMethod |
2288 "return strings which need translation from a help-spec method" |
2265 "return strings which need translation from a help-spec method" |
2289 |
2266 |
2290 |codeStrings matcher parseTree resourceKeys| |
2267 |codeStrings matcher parseTree resourceKeys| |
2291 |
2268 |
2292 parseTree := RBParser |
2269 parseTree := RBParser |
2293 parseMethod:aMethod source |
2270 parseMethod:aMethod source |
2294 onError: [:str :pos | Transcript showCR:str. Transcript showCR:pos. |
2271 onError: [:str :pos | Transcript showCR:str. Transcript showCR:pos. |
2295 nil]. |
2272 nil]. |
2296 parseTree isNil ifTrue:[^ #() ]. |
2273 parseTree isNil ifTrue:[^ #() ]. |
2297 |
2274 |
2298 codeStrings := |
2275 codeStrings := |
2299 #( |
2276 #( |
2300 '`@dict addPairsFrom: `#helpKeysAndStrings' |
2277 '`@dict addPairsFrom: `#helpKeysAndStrings' |
2301 '^ `#lit' |
2278 '^ `#lit' |
2302 ). |
2279 ). |
2303 |
2280 |
2304 resourceKeys := Set new. |
2281 resourceKeys := Set new. |
2305 |
2282 |
2306 matcher := ParseTreeSearcher new. |
2283 matcher := ParseTreeSearcher new. |
2307 matcher |
2284 matcher |
2308 matchesAnyOf: codeStrings |
2285 matchesAnyOf: codeStrings |
2309 do: [:aNode :answer | |
2286 do: [:aNode :answer | |
2310 |sel argNode arg| |
2287 |sel argNode arg| |
2311 |
2288 |
2312 aNode isReturn ifTrue:[ |
2289 aNode isReturn ifTrue:[ |
2313 "/ a ^ #(...) |
2290 "/ a ^ #(...) |
2314 aNode value isLiteralArray ifTrue:[ |
2291 aNode value isLiteralArray ifTrue:[ |
2315 aNode value value pairWiseDo:[:helpKey :helpString | |
2292 aNode value value pairWiseDo:[:helpKey :helpString | |
2316 self rememberMethod:aMethod usingKey:helpString. |
2293 self rememberMethod:aMethod usingKey:helpString. |
2317 resourceKeys add:helpString. |
2294 resourceKeys add:helpString. |
2318 ]. |
2295 ]. |
2319 ]. |
2296 ]. |
2320 ] ifFalse:[ |
2297 ] ifFalse:[ |
2321 sel := aNode selector. |
2298 sel := aNode selector. |
2322 (sel startsWith:'addPairsFrom:') ifTrue:[ |
2299 (sel startsWith:'addPairsFrom:') ifTrue:[ |
2323 argNode := aNode arguments at:1. |
2300 argNode := aNode arguments at:1. |
2324 argNode isLiteralArray ifTrue:[ |
2301 argNode isLiteralArray ifTrue:[ |
2325 arg := argNode value. |
2302 arg := argNode value. |
2326 arg doWithIndex:[:el :index | |
2303 arg doWithIndex:[:el :index | |
2327 index even ifTrue:[ |
2304 index even ifTrue:[ |
2328 el isString ifTrue:[ |
2305 el isString ifTrue:[ |
2329 self rememberMethod:aMethod usingKey:el. |
2306 self rememberMethod:aMethod usingKey:el. |
2330 resourceKeys add:el. |
2307 resourceKeys add:el. |
2331 ] |
2308 ] |
2332 ]. |
2309 ]. |
2333 ]. |
2310 ]. |
2334 ] ifFalse:[ |
2311 ] ifFalse:[ |
2335 Transcript halt |
2312 Transcript halt |
2336 showCR:(resources |
2313 showCR:(resources |
2337 string:'Cannot derive resourceKey from non-literal array: %1 in %2' |
2314 string:'Cannot derive resourceKey from non-literal array: %1 in %2' |
2338 with:argNode formattedCode |
2315 with:argNode formattedCode |
2339 with:aMethod selector). |
2316 with:aMethod selector). |
2340 ]. |
2317 ]. |
2341 ]. |
2318 ]. |
2342 ]. |
2319 ]. |
2343 aNode |
2320 aNode |
2344 ]. |
2321 ]. |
2345 |
2322 |
2346 matcher executeTree: parseTree initialAnswer: nil. |
2323 matcher executeTree: parseTree initialAnswer: nil. |
2347 ^ resourceKeys |
2324 ^ resourceKeys |
2348 ! |
2325 ! |
2349 |
2326 |
2354 |
2331 |
2355 menu := aMethod mclass theNonMetaclass perform:aMethod selector. |
2332 menu := aMethod mclass theNonMetaclass perform:aMethod selector. |
2356 menu isNil ifTrue:[ ^ #() ]. |
2333 menu isNil ifTrue:[ ^ #() ]. |
2357 |
2334 |
2358 (menu isKindOf:Menu) ifFalse:[ |
2335 (menu isKindOf:Menu) ifFalse:[ |
2359 menu := Menu new fromLiteralArrayEncoding:menu |
2336 menu := Menu new fromLiteralArrayEncoding:menu |
2360 ]. |
2337 ]. |
2361 |
2338 |
2362 resourceKeys := Set new. |
2339 resourceKeys := Set new. |
2363 menu allItemsDo:[:aMenuItem | |
2340 menu allItemsDo:[:aMenuItem | |
2364 aMenuItem translateLabel ifTrue:[ |
2341 aMenuItem translateLabel ifTrue:[ |
2365 (aMenuItem isSeparatorItem or:[aMenuItem isMenuSlice]) ifFalse:[ |
2342 (aMenuItem isSeparatorItem or:[aMenuItem isMenuSlice]) ifFalse:[ |
2366 self rememberMethod:aMethod usingKey:aMenuItem label. |
2343 self rememberMethod:aMethod usingKey:aMenuItem label. |
2367 resourceKeys add:aMenuItem label. |
2344 resourceKeys add:aMenuItem label. |
2368 ] |
2345 ] |
2369 ] |
2346 ] |
2370 ]. |
2347 ]. |
2371 ^ resourceKeys |
2348 ^ resourceKeys |
2372 ! |
2349 ! |
2373 |
2350 |
2374 extractTranslationsFromMethod:aMethod |
2351 extractTranslationsFromMethod:aMethod |
2375 "return strings which need translation from a method." |
2352 "return strings which need translation from a method." |
2376 |
2353 |
2377 |mResources| |
2354 |mResources| |
2378 |
2355 |
2379 mResources := aMethod resources. |
2356 mResources := aMethod resources. |
2380 mResources notNil ifTrue:[ |
2357 mResources notNil ifTrue:[ |
2381 (mResources includesKey:#menu) ifTrue:[ |
2358 (mResources includesKey:#menu) ifTrue:[ |
2382 ^ self extractTranslationsFromMenuSpecMethod:aMethod. |
2359 ^ self extractTranslationsFromMenuSpecMethod:aMethod. |
2383 ]. |
2360 ]. |
2384 (mResources includesKey:#canvas) ifTrue:[ |
2361 (mResources includesKey:#canvas) ifTrue:[ |
2385 ^ self extractTranslationsFromUISpecMethod:aMethod. |
2362 ^ self extractTranslationsFromUISpecMethod:aMethod. |
2386 ]. |
2363 ]. |
2387 (mResources includesKey:#help) ifTrue:[ |
2364 (mResources includesKey:#help) ifTrue:[ |
2388 ^ self extractTranslationsFromHelpSpecMethod:aMethod. |
2365 ^ self extractTranslationsFromHelpSpecMethod:aMethod. |
2389 ]. |
2366 ]. |
2390 (mResources includesKey:#tableColumns) ifTrue:[ |
2367 (mResources includesKey:#tableColumns) ifTrue:[ |
2391 ^ self extractTranslationsFromTableColumnsSpecMethod:aMethod. |
2368 ^ self extractTranslationsFromTableColumnsSpecMethod:aMethod. |
2392 ]. |
2369 ]. |
2393 |
2370 |
2394 ^ self extractTranslationsFromSpecMethod:aMethod. |
2371 ^ self extractTranslationsFromSpecMethod:aMethod. |
2395 ]. |
2372 ]. |
2396 ^ self extractTranslationsFromMethodsCode:aMethod |
2373 ^ self extractTranslationsFromMethodsCode:aMethod |
2397 ! |
2374 ! |
2398 |
2375 |
2399 extractTranslationsFromMethodsCode:aMethod |
2376 extractTranslationsFromMethodsCode:aMethod |
2401 detects messages to the resource translation mechanism" |
2378 detects messages to the resource translation mechanism" |
2402 |
2379 |
2403 |codeStrings matcher parseTree resourceKeys| |
2380 |codeStrings matcher parseTree resourceKeys| |
2404 |
2381 |
2405 parseTree := RBParser |
2382 parseTree := RBParser |
2406 parseMethod:aMethod source |
2383 parseMethod:aMethod source |
2407 onError: [:str :pos | Transcript showCR:str. Transcript showCR:pos. |
2384 onError: [:str :pos | Transcript showCR:str. Transcript showCR:pos. |
2408 nil]. |
2385 nil]. |
2409 parseTree isNil ifTrue:[^ #() ]. |
2386 parseTree isNil ifTrue:[^ #() ]. |
2410 |
2387 |
2411 codeStrings := |
2388 codeStrings := |
2412 #( |
2389 #( |
2413 'resources `@msg: `@args' |
2390 'resources `@msg: `@args' |
2414 'self resources `@msg: `@args' |
2391 'self resources `@msg: `@args' |
2415 'self class resources `@msg: `@args' |
2392 'self class resources `@msg: `@args' |
2416 'self class classResources `@msg: `@args' |
2393 'self class classResources `@msg: `@args' |
2417 'self classResources `@msg: `@args' |
2394 'self classResources `@msg: `@args' |
2418 '`V classResources `@msg: `@args' |
2395 '`V classResources `@msg: `@args' |
2419 ). |
2396 ). |
2420 |
2397 |
2421 resourceKeys := Set new. |
2398 resourceKeys := Set new. |
2422 |
2399 |
2423 matcher := ParseTreeSearcher new. |
2400 matcher := ParseTreeSearcher new. |
2424 matcher |
2401 matcher |
2425 matchesAnyOf: codeStrings |
2402 matchesAnyOf: codeStrings |
2426 do: [:aNode :answer | |
2403 do: [:aNode :answer | |
2427 |sel keyStringArgNode keyStringArg| |
2404 |sel keyStringArgNode keyStringArg| |
2428 |
2405 |
2429 sel := aNode selector. |
2406 sel := aNode selector. |
2430 ((sel startsWith:'string:') or:[(sel startsWith:'at:') or:[sel startsWith:'stringWithCRs:']]) ifTrue:[ |
2407 ((sel startsWith:'string:') or:[(sel startsWith:'at:') or:[sel startsWith:'stringWithCRs:']]) ifTrue:[ |
2431 keyStringArgNode := aNode arguments at:1. |
2408 keyStringArgNode := aNode arguments at:1. |
2432 (keyStringArg := self literalStringOrStringConcatenation:keyStringArgNode) notNil ifTrue:[ |
2409 (keyStringArg := self literalStringOrStringConcatenation:keyStringArgNode) notNil ifTrue:[ |
2433 self rememberMethod:aMethod usingKey:keyStringArg. |
2410 self rememberMethod:aMethod usingKey:keyStringArg. |
2434 resourceKeys add:keyStringArg. |
2411 resourceKeys add:keyStringArg. |
2435 ] ifFalse:[ |
2412 ] ifFalse:[ |
2436 Transcript |
2413 Transcript |
2437 showCR:(resources |
2414 showCR:(resources |
2438 string:'[LanguageTranslator] warning: Cannot derive resourceKey from non-string: %1 in %2' |
2415 string:'[LanguageTranslator] warning: Cannot derive resourceKey from non-string: %1 in %2' |
2439 with:keyStringArgNode formattedCode |
2416 with:keyStringArgNode formattedCode |
2440 with:aMethod whoString). |
2417 with:aMethod whoString). |
2441 ]. |
2418 ]. |
2442 ]. |
2419 ]. |
2443 aNode |
2420 aNode |
2444 ]. |
2421 ]. |
2445 |
2422 |
2446 matcher executeTree: parseTree initialAnswer: nil. |
2423 matcher executeTree: parseTree initialAnswer: nil. |
2447 ^ resourceKeys |
2424 ^ resourceKeys |
2448 |
2425 |
2449 "Modified: / 19-02-2015 / 11:42:04 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
2426 "Modified: / 19-02-2015 / 11:42:04 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
2460 |
2437 |
2461 columnDescription := aMethod mclass theNonMetaclass perform:aMethod selector. |
2438 columnDescription := aMethod mclass theNonMetaclass perform:aMethod selector. |
2462 columnDescription isNil ifTrue:[ ^ #() ]. |
2439 columnDescription isNil ifTrue:[ ^ #() ]. |
2463 |
2440 |
2464 (columnDescription first isKindOf:DataSetColumnSpec) ifFalse:[ |
2441 (columnDescription first isKindOf:DataSetColumnSpec) ifFalse:[ |
2465 columnDescription := columnDescription collect:[:el | DataSetColumnSpec new fromLiteralArrayEncoding:el]. |
2442 columnDescription := columnDescription collect:[:el | DataSetColumnSpec new fromLiteralArrayEncoding:el]. |
2466 ]. |
2443 ]. |
2467 |
2444 |
2468 resourceKeys := Set new. |
2445 resourceKeys := Set new. |
2469 columnDescription do:[:aColumnSpec | |
2446 columnDescription do:[:aColumnSpec | |
2470 aColumnSpec translateLabel ifTrue:[ |
2447 aColumnSpec translateLabel ifTrue:[ |
2471 self rememberMethod:aMethod usingKey:aColumnSpec label. |
2448 self rememberMethod:aMethod usingKey:aColumnSpec label. |
2472 resourceKeys add:aColumnSpec label. |
2449 resourceKeys add:aColumnSpec label. |
2473 ] |
2450 ] |
2474 ]. |
2451 ]. |
2475 ^ resourceKeys |
2452 ^ resourceKeys |
2476 ! |
2453 ! |
2477 |
2454 |
2478 extractTranslationsFromUISpecMethod:aMethod |
2455 extractTranslationsFromUISpecMethod:aMethod |
2479 "return strings which need translation from a UI-spec method" |
2456 "return strings which need translation from a UI-spec method" |
2480 |
2457 |
2481 |spec resourceKeys visitor| |
2458 |spec resourceKeys visitor| |
2482 |
2459 |
2483 spec := aMethod mclass theNonMetaclass perform:aMethod selector. |
2460 spec := aMethod mclass theNonMetaclass perform:aMethod selector. |
2484 spec isNil ifTrue:[ ^ #() ]. |
2461 spec isNil ifTrue:[ ^ #() ]. |
2485 |
2462 |
2486 (spec isKindOf:UISpecification) ifFalse:[ |
2463 (spec isKindOf:UISpecification) ifFalse:[ |
2487 spec := UISpecification from:spec |
2464 spec := UISpecification from:spec |
2488 ]. |
2465 ]. |
2489 |
2466 |
2490 resourceKeys := Set new. |
2467 resourceKeys := Set new. |
2491 |
2468 |
2492 visitor := UISpecVisitor new. |
2469 visitor := UISpecVisitor new. |
2493 spec acceptVisitor:visitor. |
2470 spec acceptVisitor:visitor. |
2494 visitor translatedLabels do:[:each | |
2471 visitor translatedLabels do:[:each | |
2495 self rememberMethod:aMethod usingKey:each. |
2472 self rememberMethod:aMethod usingKey:each. |
2496 ]. |
2473 ]. |
2497 ^ visitor translatedLabels |
2474 ^ visitor translatedLabels |
2498 ! |
2475 ! |
2499 |
2476 |
2500 literalStringOrStringConcatenation:aParseNode |
2477 literalStringOrStringConcatenation:aParseNode |
2501 "nil if not a literal or a string concatenation" |
2478 "nil if not a literal or a string concatenation" |
2502 |
2479 |
2503 aParseNode isLiteralString ifTrue:[^ aParseNode value]. |
2480 aParseNode isLiteralString ifTrue:[^ aParseNode value]. |
2504 (aParseNode isMessage and:[aParseNode selector == #,]) ifTrue:[ |
2481 (aParseNode isMessage and:[aParseNode selector == #,]) ifTrue:[ |
2505 |leftString rightString| |
2482 |leftString rightString| |
2506 |
2483 |
2507 aParseNode receiver isLiteralString ifTrue:[ |
2484 aParseNode receiver isLiteralString ifTrue:[ |
2508 leftString := aParseNode receiver value |
2485 leftString := aParseNode receiver value |
2509 ] ifFalse:[ |
2486 ] ifFalse:[ |
2510 leftString := self literalStringOrStringConcatenation:aParseNode receiver. |
2487 leftString := self literalStringOrStringConcatenation:aParseNode receiver. |
2511 ]. |
2488 ]. |
2512 aParseNode arguments first isLiteralString ifTrue:[ |
2489 aParseNode arguments first isLiteralString ifTrue:[ |
2513 rightString := aParseNode arguments first value |
2490 rightString := aParseNode arguments first value |
2514 ] ifFalse:[ |
2491 ] ifFalse:[ |
2515 rightString := self literalStringOrStringConcatenation:aParseNode arguments first. |
2492 rightString := self literalStringOrStringConcatenation:aParseNode arguments first. |
2516 ]. |
2493 ]. |
2517 (leftString notNil and:[rightString notNil]) ifTrue:[ |
2494 (leftString notNil and:[rightString notNil]) ifTrue:[ |
2518 ^ leftString , rightString |
2495 ^ leftString , rightString |
2519 ]. |
2496 ]. |
2520 ]. |
2497 ]. |
2521 ^ nil |
2498 ^ nil |
2522 ! |
2499 ! |
2523 |
2500 |
2524 recordNewTranslation:aString |
2501 recordNewTranslation:aString |
2525 "called from recorder, when the monitored application does a translation" |
2502 "called from recorder, when the monitored application does a translation" |
2526 |
2503 |
2527 self addAllTranslations:{ aString } |
2504 self addAllTranslations:{ aString } |
2528 ! |
2505 ! |
2529 |
2506 |
2530 rememberMethod:aMethod usingKey:aKey |
2507 rememberMethod:aMethod usingKey:aKey |
2531 (methodsUsingKey at:aKey ifAbsentPut:[Set new]) add:aMethod |
2508 (methodsUsingKey at:aKey ifAbsentPut:[Set new]) add:aMethod |
2668 orderedAssociations := keyStringsToLanguageMappings orderedLanguageMappingsAssociationsFor: lang. |
2645 orderedAssociations := keyStringsToLanguageMappings orderedLanguageMappingsAssociationsFor: lang. |
2669 |
2646 |
2670 maxKeySize := keyStringsToLanguageMappings maxKeySizeForLanguage: lang. |
2647 maxKeySize := keyStringsToLanguageMappings maxKeySizeForLanguage: lang. |
2671 |
2648 |
2672 orderedAssociations do:[:association | |
2649 orderedAssociations do:[:association | |
2673 "use #basicStoreString to avoid implicit utf8Encoding for UnicodeStrings" |
2650 "use #basicStoreString to avoid implicit utf8Encoding for UnicodeStrings" |
2674 aStream nextPutAll: ((characterEncoder encodeString:association key basicStoreString) paddedTo: maxKeySize) ; |
2651 aStream nextPutAll: ((characterEncoder encodeString:association key basicStoreString) paddedTo: maxKeySize) ; |
2675 tab; |
2652 tab; |
2676 nextPutAll: (characterEncoder encodeString: association value basicStoreString); |
2653 nextPutAll: (characterEncoder encodeString: association value basicStoreString); |
2677 cr. |
2654 cr. |
2678 ]. |
2655 ]. |
2679 ! |
2656 ! |
2680 |
2657 |
2681 readResourceFile:aFilename asLanguage:lang |
2658 readResourceFile:aFilename asLanguage:lang |
2682 |resourcePack inStream lineString encoding decoder sortedKeys remainingKeys| |
2659 |resourcePack inStream lineString encoding decoder sortedKeys remainingKeys| |
2683 |
2660 |
2684 aFilename exists ifFalse:[ |
2661 aFilename exists ifFalse:[ |
2685 Dialog information:(resources string:'Language file: "%1" does not exist' with:aFilename baseName). |
2662 Dialog information:(resources string:'Language file: "%1" does not exist' with:aFilename baseName). |
2686 ^ self |
2663 ^ self |
2687 ]. |
2664 ]. |
2688 |
2665 |
2689 resourcePack := ResourcePack new. |
2666 resourcePack := ResourcePack new. |
2690 |
2667 |
2691 inStream := aFilename readStream. |
2668 inStream := aFilename readStream. |
2692 [inStream atEnd] whileFalse:[ |
2669 [inStream atEnd] whileFalse:[ |
2693 lineString := inStream nextLine. |
2670 lineString := inStream nextLine. |
2694 (lineString notEmpty |
2671 (lineString notEmpty |
2695 and:[ (lineString startsWith:';') not and:[ (lineString startsWith:'"/') not]]) ifTrue:[ |
2672 and:[ (lineString startsWith:';') not and:[ (lineString startsWith:'"/') not]]) ifTrue:[ |
2696 ((lineString startsWith:'#') and:[(lineString startsWith:'#(') not]) ifTrue:[ |
2673 ((lineString startsWith:'#') and:[(lineString startsWith:'#(') not]) ifTrue:[ |
2697 lineString := (lineString copyFrom:2) withoutSeparators. |
2674 lineString := (lineString copyFrom:2) withoutSeparators. |
2698 (lineString startsWith:'encoding ') ifTrue:[ |
2675 (lineString startsWith:'encoding ') ifTrue:[ |
2699 encoding := ResourcePack extractEncodingFromLine:lineString. |
2676 encoding := ResourcePack extractEncodingFromLine:lineString. |
2700 decoder := CharacterEncoder encoderFor:encoding ifAbsent:nil. |
2677 decoder := CharacterEncoder encoderFor:encoding ifAbsent:nil. |
2701 ]. |
2678 ]. |
2702 ] ifFalse:[ |
2679 ] ifFalse:[ |
2703 ResourcePack |
2680 ResourcePack |
2704 processResourceLine:lineString |
2681 processResourceLine:lineString |
2705 encoding:decoder |
2682 encoding:decoder |
2706 file:aFilename pathName |
2683 file:aFilename pathName |
2707 printErrorWith:[:msg | Transcript showCR:msg ] |
2684 printErrorWith:[:msg | Transcript showCR:msg ] |
2708 for:resourcePack |
2685 for:resourcePack |
2709 keepUselessTranslations:true. |
2686 keepUselessTranslations:true. |
2710 ]. |
2687 ]. |
2711 ]. |
2688 ]. |
2712 ]. |
2689 ]. |
2713 inStream close. |
2690 inStream close. |
2714 |
2691 |
2715 sortedKeys := (resourcePack keys select:[:k | k isString]) asSortedCollection. |
2692 sortedKeys := (resourcePack keys select:[:k | k isString]) asSortedCollection. |
2716 remainingKeys := resourcePack keys select:[:k | k isString not]. |
2693 remainingKeys := resourcePack keys select:[:k | k isString not]. |
2717 |
2694 |
2718 keyStringsToLanguageMappings atLanguage: lang putFilename: aFilename. |
2695 keyStringsToLanguageMappings atLanguage: lang putFilename: aFilename. |
2719 keyStringsToLanguageMappings atLanguage: lang putEncoder: decoder. |
2696 keyStringsToLanguageMappings atLanguage: lang putEncoder: decoder. |
2720 |
2697 |
2721 sortedKeys do:[:k | |
2698 sortedKeys do:[:k | |
2722 keyStringsToLanguageMappings at:k language:lang put:(resourcePack at:k) sendChange:false |
2699 keyStringsToLanguageMappings at:k language:lang put:(resourcePack at:k) sendChange:false |
2723 ]. |
2700 ]. |
2724 remainingKeys do:[:k | |
2701 remainingKeys do:[:k | |
2725 keyStringsToLanguageMappings at:k language:lang put:(resourcePack at:k) sendChange:false |
2702 keyStringsToLanguageMappings at:k language:lang put:(resourcePack at:k) sendChange:false |
2726 ]. |
2703 ]. |
2727 keyStringsToLanguageMappings changed. |
2704 keyStringsToLanguageMappings changed. |
2728 ! |
2705 ! |
2729 |
2706 |
2730 saveLanguage: lang |
2707 saveLanguage: lang |