Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] extract index and compiled translations into extension #1355

Merged
merged 1 commit into from
Aug 4, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package fr.adrienbrault.idea.symfony2plugin.extension;

import com.intellij.openapi.project.Project;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.PsiElement;
import org.jetbrains.annotations.NotNull;

import java.util.Collection;

/**
* Provide extension implementation for new translator source
*
* @author Daniel Espendiller <daniel@espendiller.net>
*/
public interface TranslatorProvider {
boolean hasTranslationKey(@NotNull Project project, @NotNull String keyName, @NotNull String domainName);
boolean hasDomain(@NotNull Project project, @NotNull String domainName);

@NotNull
Collection<TranslatorProviderDict.TranslationDomain> getTranslationDomains(@NotNull Project project);

@NotNull
Collection<PsiElement> getTranslationTargets(@NotNull Project project, @NotNull String translationKey, @NotNull String domain);

@NotNull
Collection<VirtualFile> getDomainPsiFiles(final Project project, @NotNull String domainName);

@NotNull
Collection<TranslatorProviderDict.TranslationKey> getTranslationsForDomain(@NotNull Project project, @NotNull String domainName);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
package fr.adrienbrault.idea.symfony2plugin.extension;

import org.jetbrains.annotations.NotNull;

/**
* @author Daniel Espendiller <daniel@espendiller.net>
*/
public class TranslatorProviderDict {
public static class TranslationDomain {
@NotNull
private final String domain;
private final boolean weak;

public TranslationDomain(@NotNull String domain) {
this.domain = domain;
this.weak = false;
}

public TranslationDomain(@NotNull String domain, boolean weak) {
this.domain = domain;
this.weak = weak;
}

@NotNull
public String getDomain() {
return domain;
}

public boolean isWeak() {
return weak;
}
}

public static class TranslationKey {
@NotNull
private final String domain;
private final boolean weak;

public TranslationKey(@NotNull String domain) {
this.domain = domain;
this.weak = false;
}

public TranslationKey(@NotNull String domain, boolean weak) {
this.domain = domain;
this.weak = weak;
}

@NotNull
public String getDomain() {
return domain;
}

public boolean isWeak() {
return weak;
}
}
}
Loading